Skip to content

Commit

Permalink
Switch to new @cspotcode/source-map-support, using trace-mapping (#1729)
Browse files Browse the repository at this point in the history
* WIP

* stuff

* fix

* experimenting

* try new changes

* fix

* update

* bump

* fix

* bump

* bump

* fix

* bump

* cleanup
  • Loading branch information
cspotcode committed May 1, 2022
1 parent 9e25557 commit 17aad13
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .vscode/launch.json
Expand Up @@ -11,6 +11,18 @@
"skipFiles": [
"<node_internals>/**/*.js"
],
},
{
"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"],
"program": "throw error.ts",
"outputCapture": "std",
"skipFiles": [
"<node_internals>/**/*.js"
],
}
],
}
41 changes: 36 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -157,7 +157,7 @@
}
},
"dependencies": {
"@cspotcode/source-map-support": "0.7.0",
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
Expand Down
12 changes: 7 additions & 5 deletions src/test/esm-loader.spec.ts
Expand Up @@ -48,22 +48,24 @@ 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'),
}
);
expect(err).not.toBe(null);
const expectedModuleUrl = pathToFileURL(
join(TEST_DIR, './esm/throw error.ts')
).toString();
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 (${expectedModuleUrl}:100:17)`,
].join('\n')
);
});
Expand Down

0 comments on commit 17aad13

Please sign in to comment.