From 9cd7d598405f8bf6600775827f870848fd3e120a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 5 May 2020 23:13:04 +0200 Subject: 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. --- deno_typescript/compiler_main.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'deno_typescript/compiler_main.js') 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, -- cgit v1.2.3