diff options
author | Johannes Rieken <johannes.rieken@gmail.com> | 2022-06-27 13:01:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-27 13:01:17 +0300 |
commit | 0182e175eb9b67163878b6230377c2e2f41b2981 (patch) | |
tree | f34637a127ce2284b60b49f67ae220a837c6512a /build | |
parent | e5301ee66cfc245c01945e51e5e34db7004b7da1 (diff) |
fix transpile on windows (#153285)
make sure to normalize paths before entering internal TS API, also add better error logging to know what file paths fail
Diffstat (limited to 'build')
-rw-r--r-- | build/lib/tsb/transpiler.js | 33 | ||||
-rw-r--r-- | build/lib/tsb/transpiler.ts | 38 |
2 files changed, 46 insertions, 25 deletions
diff --git a/build/lib/tsb/transpiler.js b/build/lib/tsb/transpiler.js index 7da255d529f..38e6b5c00e4 100644 --- a/build/lib/tsb/transpiler.js +++ b/build/lib/tsb/transpiler.js @@ -121,20 +121,29 @@ class Transpiler { this._allJobs = []; logFn('Transpile', `will use ${Transpiler.P} transpile worker`); this._getOutputFileName = (file) => { - if (!_cmdLine.options.configFilePath) { - // this is needed for the INTERNAL getOutputFileNames-call below... - _cmdLine.options.configFilePath = configFilePath; - } - const isDts = file.endsWith('.d.ts'); - if (isDts) { - file = file.slice(0, -5) + '.ts'; - _cmdLine.fileNames.push(file); + try { + // windows: path-sep normalizing + file = ts.normalizePath(file); + if (!_cmdLine.options.configFilePath) { + // this is needed for the INTERNAL getOutputFileNames-call below... + _cmdLine.options.configFilePath = configFilePath; + } + const isDts = file.endsWith('.d.ts'); + if (isDts) { + file = file.slice(0, -5) + '.ts'; + _cmdLine.fileNames.push(file); + } + const outfile = ts.getOutputFileNames(_cmdLine, file, true)[0]; + if (isDts) { + _cmdLine.fileNames.pop(); + } + return outfile; } - const outfile = ts.getOutputFileNames(_cmdLine, file, true)[0]; - if (isDts) { - _cmdLine.fileNames.pop(); + catch (err) { + console.error(file, _cmdLine.fileNames); + console.error(err); + throw new err; } - return outfile; }; } async join() { diff --git a/build/lib/tsb/transpiler.ts b/build/lib/tsb/transpiler.ts index 3afc3547dd5..7bd789ef6eb 100644 --- a/build/lib/tsb/transpiler.ts +++ b/build/lib/tsb/transpiler.ts @@ -166,23 +166,35 @@ export class Transpiler { // very complicated logic to re-use TS internal functions to know the output path // given a TS input path and its config type InternalTsApi = typeof ts & { + normalizePath(path: string): string; getOutputFileNames(commandLine: ts.ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; }; this._getOutputFileName = (file) => { - if (!_cmdLine.options.configFilePath) { - // this is needed for the INTERNAL getOutputFileNames-call below... - _cmdLine.options.configFilePath = configFilePath; - } - const isDts = file.endsWith('.d.ts'); - if (isDts) { - file = file.slice(0, -5) + '.ts'; - _cmdLine.fileNames.push(file); - } - const outfile = (<InternalTsApi>ts).getOutputFileNames(_cmdLine, file, true)[0]; - if (isDts) { - _cmdLine.fileNames.pop(); + try { + + // windows: path-sep normalizing + file = (<InternalTsApi>ts).normalizePath(file); + + if (!_cmdLine.options.configFilePath) { + // this is needed for the INTERNAL getOutputFileNames-call below... + _cmdLine.options.configFilePath = configFilePath; + } + const isDts = file.endsWith('.d.ts'); + if (isDts) { + file = file.slice(0, -5) + '.ts'; + _cmdLine.fileNames.push(file); + } + const outfile = (<InternalTsApi>ts).getOutputFileNames(_cmdLine, file, true)[0]; + if (isDts) { + _cmdLine.fileNames.pop(); + } + return outfile; + + } catch (err) { + console.error(file, _cmdLine.fileNames); + console.error(err); + throw new err; } - return outfile; }; } |