diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-05 23:13:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-05 23:13:04 +0200 |
commit | 9cd7d598405f8bf6600775827f870848fd3e120a (patch) | |
tree | b28f5c65b1d8d5d7c3a68c09d384171dab097881 /deno_typescript/compiler_main.js | |
parent | 5875bb9c0d5949682191e4b2592433e975abce4d (diff) |
fix(cli): fix paths in internal stack traces (#5093)
This commit updates "deno_typescript" crate to properly map
bundle entrypoint file to internal specifier.
All import specifiers were remapped from "file:///a/b/c.ts" to
"$deno$/a/b/c.ts", but that was not the case for entrypoint file
"main.ts" and "compiler.ts".
Because of that internal stack traces were inconsistent; showing
"file:///some/random/path/on/ci/machine.ts" URL in frames that
originate from "main.ts" or "compiler.ts" and "$deno$/file.ts"
for all other imports.
Diffstat (limited to 'deno_typescript/compiler_main.js')
-rw-r--r-- | deno_typescript/compiler_main.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/deno_typescript/compiler_main.js b/deno_typescript/compiler_main.js index 234ed6002..31f539a27 100644 --- a/deno_typescript/compiler_main.js +++ b/deno_typescript/compiler_main.js @@ -19,14 +19,25 @@ function main(configText, rootNames) { const host = new Host(); - assert(rootNames.length > 0); - + assert(rootNames.length === 1); + // If root file is external file, ie. URL with "file://" + // then create an internal name - in case of bundling + // cli runtime this is always true. + const rootFile = rootNames[0]; + const result = externalSpecifierRegEx.exec(rootFile); + let rootSpecifier = rootFile; + if (result) { + const [, specifier] = result; + const internalSpecifier = `$deno$${specifier}`; + moduleMap.set(internalSpecifier, rootFile); + rootSpecifier = internalSpecifier; + } const { options, diagnostics } = configure(configText); handleDiagnostics(host, diagnostics); println(`>>> TS config: ${JSON.stringify(options)}`); - const program = ts.createProgram(rootNames, options, host); + const program = ts.createProgram([rootSpecifier], options, host); handleDiagnostics( host, |