-
-
Notifications
You must be signed in to change notification settings - Fork 549
Open
Description
Search Terms
sourcemap, source map, 20
Expected Behavior
Source maps map the correct line even if the file has a newline (Which gets removed by tsc)
Actual Behavior
On Node 20.1 the mapping excludes the newlines.
Steps to reproduce the problem
Run the repro repo yarn run test on Node 20.1 and Node 19 and observe the difference in stack locations for the thrown error.
Node 20.1:
Error: Error
at file:///Users/richard/git/tsnodesourcemaptest/index.ts:7:7
at ModuleJob.run (node:internal/modules/esm/module_job:192:25)
Node 19:
Error: Error
at file:///Users/richard/git/tsnodesourcemaptest/index.ts:12:7
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
There is also a test-js script included which will compile and run the output JS file with --enable-source-maps. In this case the source map is correct on both versions.
Minimal reproduction
https://github.com/richardsimko/ts-node-sourcemap-bug
Specifications
- ts-node version: 10.9.1
- node version: 20.1
- TypeScript version: 5.0.4
- tsconfig.json, if you're using one:
{
"compilerOptions": {
"outDir": "./build",
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "node",
"sourceMap": true
},
"ts-node": {
"files": true,
"swc": true
},
"include": ["**/*.ts"]
}- package.json:
{
"name": "tsnodesourcemaptest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "node --loader ts-node/esm index.ts",
"test-js": "tsc && node --enable-source-maps build/index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"@swc/core": "^1.3.56",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
}
}- Operating system and version: macOS 13.3
- If Windows, are you using WSL or WSL2?:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels