From 7f0bdfc4b77b5a1142191dcd8c735b649221d034 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Thu, 21 Apr 2022 17:59:59 -0400 Subject: [PATCH 01/14] WIP --- package-lock.json | 31 ++++++++++++++++++++++--------- package.json | 2 +- src/index.ts | 1 + src/test/esm-loader.spec.ts | 11 +++++++++-- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index bb969e51a..1bee5999b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -311,17 +311,11 @@ } } }, - "@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" - }, "@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#c6aa0320f440c064467fb588a772fe129679934a", + "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" } }, "@istanbuljs/load-nyc-config": { @@ -401,6 +395,25 @@ "chalk": "^4.0.0" } }, + "@jridgewell/resolve-uri": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", + "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==" + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.11", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", + "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==" + }, + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "@microsoft/api-extractor": { "version": "7.19.4", "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.19.4.tgz", diff --git a/package.json b/package.json index f48dda011..f300fa30c 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ } }, "dependencies": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", diff --git a/src/index.ts b/src/index.ts index ff2186ba3..a34144445 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1551,6 +1551,7 @@ function updateSourceMap(sourceMapText: string, fileName: string) { sourceMap.file = fileName; sourceMap.sources = [fileName]; delete sourceMap.sourceRoot; + console.dir(sourceMap); return JSON.stringify(sourceMap); } diff --git a/src/test/esm-loader.spec.ts b/src/test/esm-loader.spec.ts index 5bc9f648f..78a998d00 100644 --- a/src/test/esm-loader.spec.ts +++ b/src/test/esm-loader.spec.ts @@ -48,13 +48,15 @@ test.suite('esm', (test) => { expect(err).toBe(null); expect(stdout).toBe('foo bar baz biff libfoo\n'); }); - test('should use source maps', async () => { - const { err, stdout } = await exec( + test('should use source maps', async (t) => { + const { err, stdout, stderr } = await exec( `${CMD_ESM_LOADER_WITHOUT_PROJECT} "throw error.ts"`, { cwd: join(TEST_DIR, './esm'), } ); + t.log(stdout); + t.log(stderr); expect(err).not.toBe(null); expect(err!.message).toMatch( [ @@ -64,6 +66,11 @@ test.suite('esm', (test) => { " bar() { throw new Error('this is a demo'); }", ' ^', 'Error: this is a demo', + ` at Foo.bar (${pathToFileURL( + join(TEST_DIR, './esm/throw error.ts') + ) + .toString() + .replace(/%20/g, ' ')}:\d+)`, ].join('\n') ); }); From 167175b3b03bb00b1f05438289f1deab02825aa0 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sat, 23 Apr 2022 00:03:52 +0000 Subject: [PATCH 02/14] stuff --- package-lock.json | 23 ++++++++++++++++++++--- src/index.ts | 1 - 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1bee5999b..2ff18579b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -311,6 +311,12 @@ } } }, + "@cspotcode/source-map-consumer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", + "dev": true + }, "@cspotcode/source-map-support": { "version": "git+https://github.com/cspotcode/node-source-map-support.git#c6aa0320f440c064467fb588a772fe129679934a", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", @@ -396,9 +402,9 @@ } }, "@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==" + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.6.tgz", + "integrity": "sha512-R7xHtBSNm+9SyvpJkdQl+qrM3Hm2fea3Ef197M3mUug+v+yR+Rhfbs7PBtcBUVnIWJ4JcAdjvij+c8hXS9p5aw==" }, "@jridgewell/sourcemap-codec": { "version": "1.4.11", @@ -4576,6 +4582,17 @@ "make-error": "^1.1.1", "v8-compile-cache-lib": "^3.0.0", "yn": "3.1.1" + }, + "dependencies": { + "@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "dev": true, + "requires": { + "@cspotcode/source-map-consumer": "0.8.0" + } + } } }, "tslib": { diff --git a/src/index.ts b/src/index.ts index a34144445..ff2186ba3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1551,7 +1551,6 @@ function updateSourceMap(sourceMapText: string, fileName: string) { sourceMap.file = fileName; sourceMap.sources = [fileName]; delete sourceMap.sourceRoot; - console.dir(sourceMap); return JSON.stringify(sourceMap); } From 8fcb9ffabee1e32ec176c8216f55563370f6eafe Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sat, 23 Apr 2022 00:35:53 +0000 Subject: [PATCH 03/14] fix --- package-lock.json | 2 +- src/test/esm-loader.spec.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ff18579b..b4f89b96b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -318,7 +318,7 @@ "dev": true }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#c6aa0320f440c064467fb588a772fe129679934a", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#12a2b6f10580d564e1c04ece1934ab4675675509", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { "@jridgewell/trace-mapping": "0.3.9" diff --git a/src/test/esm-loader.spec.ts b/src/test/esm-loader.spec.ts index 78a998d00..b16307dd3 100644 --- a/src/test/esm-loader.spec.ts +++ b/src/test/esm-loader.spec.ts @@ -58,19 +58,18 @@ test.suite('esm', (test) => { t.log(stdout); t.log(stderr); expect(err).not.toBe(null); + const expectedModuleUrl = pathToFileURL( + join(TEST_DIR, './esm/throw error.ts') + ) + .toString() + .replace(/%20/g, ' '); expect(err!.message).toMatch( [ - `${pathToFileURL(join(TEST_DIR, './esm/throw error.ts')) - .toString() - .replace(/%20/g, ' ')}:100`, + `${expectedModuleUrl}:100`, " bar() { throw new Error('this is a demo'); }", ' ^', 'Error: this is a demo', - ` at Foo.bar (${pathToFileURL( - join(TEST_DIR, './esm/throw error.ts') - ) - .toString() - .replace(/%20/g, ' ')}:\d+)`, + ` at Foo.bar (${expectedModuleUrl}:100:17)`, ].join('\n') ); }); From 5c9e8114c04070fc4f365c3d28d09b13a0d10fe9 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sat, 23 Apr 2022 13:31:54 -0400 Subject: [PATCH 04/14] experimenting --- .vscode/launch.json | 12 ++++++++++++ package.json | 1 + src/index.ts | 3 ++- src/test.ts | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/test.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index 8b1ffa3f4..a411692e8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,6 +11,18 @@ "skipFiles": [ "/**/*.js" ], + }, + { + "name": "Debug 2", + "type": "pwa-node", + "request": "launch", + "cwd": "${workspaceFolder}/tests/esm", + "runtimeArgs": ["--loader", "ts-node/esm"], + "program": "throw error.ts", + "outputCapture": "std", + "skipFiles": [ + "/**/*.js" + ], } ], } diff --git a/package.json b/package.json index f300fa30c..35a98e5e3 100644 --- a/package.json +++ b/package.json @@ -168,6 +168,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", + "source-map-support-old": "npm:@cspotcode/source-map-support@^0.7.0", "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, diff --git a/src/index.ts b/src/index.ts index ff2186ba3..db62f2748 100644 --- a/src/index.ts +++ b/src/index.ts @@ -795,7 +795,8 @@ export function createFromPreloadedConfig( installSourceMapSupport(); function installSourceMapSupport() { const sourceMapSupport = - require('@cspotcode/source-map-support') as typeof _sourceMapSupport; + // require('@cspotcode/source-map-support') as typeof _sourceMapSupport; + require('source-map-support-old') as typeof _sourceMapSupport; sourceMapSupport.install({ environment: 'node', retrieveFile(pathOrUrl: string) { diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 000000000..92fde1f2b --- /dev/null +++ b/src/test.ts @@ -0,0 +1 @@ +throw new Error(); From c8fcd8b01b571c66ebcd3c652f02b49b2012dfba Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Fri, 29 Apr 2022 02:35:06 -0400 Subject: [PATCH 05/14] try new changes --- package-lock.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index b4f89b96b..d206feae2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -318,9 +318,10 @@ "dev": true }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#12a2b6f10580d564e1c04ece1934ab4675675509", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#5b79f3833f80b07ea4660118398034899b79368e", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { + "@jridgewell/resolve-uri": "^3.0.6", "@jridgewell/trace-mapping": "0.3.9" } }, From d0ddc2409cab9e5ab2101dcd3f5c44f30035da9a Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Fri, 29 Apr 2022 02:36:58 -0400 Subject: [PATCH 06/14] fix --- package-lock.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d206feae2..b6400fc81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -314,8 +314,7 @@ "@cspotcode/source-map-consumer": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { "version": "git+https://github.com/cspotcode/node-source-map-support.git#5b79f3833f80b07ea4660118398034899b79368e", @@ -4266,6 +4265,14 @@ "source-map": "^0.6.0" } }, + "source-map-support-old": { + "version": "npm:@cspotcode/source-map-support@0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "requires": { + "@cspotcode/source-map-consumer": "0.8.0" + } + }, "spawn-wrap": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", From 32ce1e0ab75923a00d7edc9bfcbde66056f80aae Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Fri, 29 Apr 2022 11:37:21 -0400 Subject: [PATCH 07/14] update --- package-lock.json | 2 +- src/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b6400fc81..5491d95bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -317,7 +317,7 @@ "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#5b79f3833f80b07ea4660118398034899b79368e", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#2b315b8ddad246617f4e643ba876df14738e779d", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { "@jridgewell/resolve-uri": "^3.0.6", diff --git a/src/index.ts b/src/index.ts index db62f2748..30521dbf5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -795,8 +795,8 @@ export function createFromPreloadedConfig( installSourceMapSupport(); function installSourceMapSupport() { const sourceMapSupport = - // require('@cspotcode/source-map-support') as typeof _sourceMapSupport; - require('source-map-support-old') as typeof _sourceMapSupport; + require('@cspotcode/source-map-support') as typeof _sourceMapSupport; + // require('source-map-support-old') as typeof _sourceMapSupport; sourceMapSupport.install({ environment: 'node', retrieveFile(pathOrUrl: string) { From 88f1bc5c6c0cc1da38c2a2f67764b0a9581d11a6 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Fri, 29 Apr 2022 14:05:01 -0400 Subject: [PATCH 08/14] bump --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 5491d95bc..8150a643e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -317,7 +317,7 @@ "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#2b315b8ddad246617f4e643ba876df14738e779d", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#69012b90a99292b91ce1ff60251cd53751572d52", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { "@jridgewell/resolve-uri": "^3.0.6", From 289656e8ddff44528adcdb758e2343e782bc2d15 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Fri, 29 Apr 2022 16:42:10 -0400 Subject: [PATCH 09/14] fix --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 8150a643e..f241e889e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -317,7 +317,7 @@ "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#69012b90a99292b91ce1ff60251cd53751572d52", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#0582d538600d6f9fd84e9a671765545f74388bc1", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { "@jridgewell/resolve-uri": "^3.0.6", From 20dcf9c67513977cada0dd4321a876e589ce41f1 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sat, 30 Apr 2022 22:41:41 -0400 Subject: [PATCH 10/14] bump --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index f241e889e..ce4ca0ecb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -317,7 +317,7 @@ "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#0582d538600d6f9fd84e9a671765545f74388bc1", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#727cbe63cd213423213beca951d69c7c476b908f", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { "@jridgewell/resolve-uri": "^3.0.6", From 0bc5a5ccd842b4e08e09200dd5daf4d6d2741f54 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 1 May 2022 00:48:42 -0400 Subject: [PATCH 11/14] bump --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index ce4ca0ecb..ec0db3364 100644 --- a/package-lock.json +++ b/package-lock.json @@ -317,7 +317,7 @@ "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#727cbe63cd213423213beca951d69c7c476b908f", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#3a68f099f3f51f22915e5c54f266626090a7396c", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { "@jridgewell/resolve-uri": "^3.0.6", From bd3c5f74e74150b0af0d180a40728b821d852487 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 1 May 2022 01:27:51 -0400 Subject: [PATCH 12/14] fix --- package-lock.json | 2 +- src/test/esm-loader.spec.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec0db3364..97d781fcf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -317,7 +317,7 @@ "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#3a68f099f3f51f22915e5c54f266626090a7396c", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#69893db3b2d686dad66d0c906dce635134232b26", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { "@jridgewell/resolve-uri": "^3.0.6", diff --git a/src/test/esm-loader.spec.ts b/src/test/esm-loader.spec.ts index b16307dd3..9be1c5c37 100644 --- a/src/test/esm-loader.spec.ts +++ b/src/test/esm-loader.spec.ts @@ -60,9 +60,7 @@ test.suite('esm', (test) => { expect(err).not.toBe(null); const expectedModuleUrl = pathToFileURL( join(TEST_DIR, './esm/throw error.ts') - ) - .toString() - .replace(/%20/g, ' '); + ).toString(); expect(err!.message).toMatch( [ `${expectedModuleUrl}:100`, From bea6e665e962c43e85165a2b02ca9996f30f97dc Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 1 May 2022 14:07:55 -0400 Subject: [PATCH 13/14] bump --- package-lock.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 97d781fcf..4afe9815c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -317,10 +317,9 @@ "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#69893db3b2d686dad66d0c906dce635134232b26", + "version": "git+https://github.com/cspotcode/node-source-map-support.git#944a35d7c67df45afa3cf3076148017528bf69ba", "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", "requires": { - "@jridgewell/resolve-uri": "^3.0.6", "@jridgewell/trace-mapping": "0.3.9" } }, From faea240347ab9236c4e6e6903d3af39288cb71ac Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 1 May 2022 15:47:44 -0400 Subject: [PATCH 14/14] cleanup --- .vscode/launch.json | 4 ++-- package-lock.json | 16 +++++----------- package.json | 3 +-- src/index.ts | 1 - src/test.ts | 1 - src/test/esm-loader.spec.ts | 2 -- 6 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 src/test.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index a411692e8..e9111194b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,11 +13,11 @@ ], }, { - "name": "Debug 2", + "name": "Debug Example: running a test fixture against local ts-node/esm loader", "type": "pwa-node", "request": "launch", "cwd": "${workspaceFolder}/tests/esm", - "runtimeArgs": ["--loader", "ts-node/esm"], + "runtimeArgs": ["--loader", "../../ts-node/esm"], "program": "throw error.ts", "outputCapture": "std", "skipFiles": [ diff --git a/package-lock.json b/package-lock.json index 4afe9815c..8dba42678 100644 --- a/package-lock.json +++ b/package-lock.json @@ -314,11 +314,13 @@ "@cspotcode/source-map-consumer": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", + "dev": true }, "@cspotcode/source-map-support": { - "version": "git+https://github.com/cspotcode/node-source-map-support.git#944a35d7c67df45afa3cf3076148017528bf69ba", - "from": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.0.tgz", + "integrity": "sha512-pOQRG+w/T1KogjiuO4uqqa+dw/IIb8kDY0ctYfiJstWv7TOTmtuAkx8ZB4YgauDNn2huHR33oruOgi45VcatOg==", "requires": { "@jridgewell/trace-mapping": "0.3.9" } @@ -4264,14 +4266,6 @@ "source-map": "^0.6.0" } }, - "source-map-support-old": { - "version": "npm:@cspotcode/source-map-support@0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", - "requires": { - "@cspotcode/source-map-consumer": "0.8.0" - } - }, "spawn-wrap": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", diff --git a/package.json b/package.json index 35a98e5e3..4483c3859 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ } }, "dependencies": { - "@cspotcode/source-map-support": "git+https://github.com/cspotcode/node-source-map-support.git#trace-mapping", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -168,7 +168,6 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "source-map-support-old": "npm:@cspotcode/source-map-support@^0.7.0", "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, diff --git a/src/index.ts b/src/index.ts index 30521dbf5..ff2186ba3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -796,7 +796,6 @@ export function createFromPreloadedConfig( function installSourceMapSupport() { const sourceMapSupport = require('@cspotcode/source-map-support') as typeof _sourceMapSupport; - // require('source-map-support-old') as typeof _sourceMapSupport; sourceMapSupport.install({ environment: 'node', retrieveFile(pathOrUrl: string) { diff --git a/src/test.ts b/src/test.ts deleted file mode 100644 index 92fde1f2b..000000000 --- a/src/test.ts +++ /dev/null @@ -1 +0,0 @@ -throw new Error(); diff --git a/src/test/esm-loader.spec.ts b/src/test/esm-loader.spec.ts index 9be1c5c37..54242abff 100644 --- a/src/test/esm-loader.spec.ts +++ b/src/test/esm-loader.spec.ts @@ -55,8 +55,6 @@ test.suite('esm', (test) => { cwd: join(TEST_DIR, './esm'), } ); - t.log(stdout); - t.log(stderr); expect(err).not.toBe(null); const expectedModuleUrl = pathToFileURL( join(TEST_DIR, './esm/throw error.ts')