| 1077 | |
| 1078 | /** Convert windows backslashes to forward slashes */ |
| 1079 | export const makeNormalizePath = (sys: OptimizerSystem) => (id: string) => { |
| 1080 | if (typeof id === 'string') { |
| 1081 | if (isWin(sys.os)) { |
| 1082 | // MIT https://github.com/sindresorhus/slash/blob/main/license |
| 1083 | // Convert Windows backslash paths to slash paths: foo\\bar ➔ foo/bar |
| 1084 | const isExtendedLengthPath = /^\\\\\?\\/.test(id); |
| 1085 | if (!isExtendedLengthPath) { |
| 1086 | const hasNonAscii = /[^\u0000-\u0080]+/.test(id); // eslint-disable-line no-control-regex |
| 1087 | if (!hasNonAscii) { |
| 1088 | id = id.replace(/\\/g, '/'); |
| 1089 | } |
| 1090 | } |
| 1091 | // windows normalize |
| 1092 | return sys.path.posix.normalize(id); |
| 1093 | } |
| 1094 | // posix normalize |
| 1095 | return sys.path.normalize(id); |
| 1096 | } |
| 1097 | return id; |
| 1098 | }; |
| 1099 | |
| 1100 | function isAdditionalFile(mod: TransformModule) { |
| 1101 | return mod.isEntry || mod.segment; |