Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to new @cspotcode/source-map-support, using trace-mapping #1729

Merged
merged 14 commits into from May 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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