Closed pauliusg closed 4 months ago
Possibly a duplicate of https://github.com/swc-project/swc-node/issues/741?
The issue was fixed in https://github.com/swc-project/swc-node/pull/742, but the changes have not yet been released.
I can confirm that issue swill exists with @swc-node/register@1.8.0. This release includes @dsyddall mentioned fix https://github.com/swc-project/swc-node/pull/742.
Updated package.json:
{
"name": "bad-sourcemaps-with-SWCRC-example",
"description": "",
"private": true,
"engines": {
"node": ">=18.19.x <19"
},
"scripts": {
"maps-good": "cross-env SWCRC= node --enable-source-maps -r @swc-node/register src/index-dev.ts",
"maps-bad": "cross-env SWCRC=true node --enable-source-maps -r @swc-node/register src/index-dev.ts"
},
"devDependencies": {
"@swc-node/register": "^1.8.0",
"@swc/cli": "^0.3.10",
"@swc/core": "^1.4.2",
"cross-env": "^7.0.3",
"typescript": "^5.1.3"
}
}
Attaching updated (with new swc-node version) minimal example project: swc-maps-issue-updated.zip
Another update, I can achieve good source maps with some additional configuration in .swcrc
file.
Source maps are bad, when .swcrc
file is empty:
{
"$schema": "https://json.schemastore.org/swcrc",
}
Source maps are good, when I add this configuration:
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"target": "esnext"
},
"sourceMaps": true
}
Probably we still can consider that issue is not fixed as it should behave the same either SWCRC file is not used or using empty SWCRC file.
I have made minimal reproducible example project only with one source file and empty
.swcrc
file. WhenSWCRC
is not set, sourcemap lines are good. But when I setSWCRC=true
sourcemap lines are wrong.Attaching minimal example project: swc-maps-issue.zip
Run without SWCRC:
npm run maps-good
Run with SWCRC:npm run maps-bad
My console output:
package.json:
tsconfig.json:
.swcrc:
index-dev.ts: