🐛 bug report
A sourcemap bug occurs when using
"transformers": {
"*.{ts,tsx}": [
"@parcel/transformer-typescript-tsc"
]
}
You get duplicate entries in the sources field in the generated .map file.
"sources": [
"node_modules/@parcel/runtime-browser-hmr/lib/runtime-2c252ac6c9223f3b.js",
"packages/a/src/server.ts",
"server.ts",
"packages/b/src/index.ts",
"index.ts",
"node_modules/@parcel/transformer-js/src/esmodule-helpers.js",
"packages/b/src/same.ts",
"same.ts",
"packages/a/src/same.ts"
],
Only the subsequent sources that only refer to the filenames are mapped (server.ts, index.ts, same.ts),
but these obviously point nowhere relative to the sourceRoot so they are invalid.
Additionally, if two filenames are identical when importing from another package in the mono repo,
their entries get overridden (notice how there is only one same.ts).
You can easily see this if you inspect the sourcemap on https://sourcemap-visualiser.vercel.app/
A sourcemap-info.json file has already been generated in the repro repo.
If you remove the transformer plugin from .parcelrc, correct sourcemaps are generated.
🎛 Configuration (.babelrc, package.json, cli command)
{
"extends": "@parcel/config-default",
"reporters": [
"...",
"@parcel/reporter-sourcemap-visualiser"
],
"transformers": {
"*.{ts,tsx}": [
"@parcel/transformer-typescript-tsc"
]
}
}
🤔 Expected Behavior
Correct sourcemap gets generated
"sources": [
"node_modules/@parcel/runtime-browser-hmr/lib/runtime-4af8d787c6a99a6a.js",
"packages/a/src/server.ts",
"packages/b/src/index.ts",
"packages/b/src/same.ts",
"node_modules/@parcel/transformer-js/src/esmodule-helpers.js",
"packages/a/src/same.ts"
]
😯 Current Behavior
An incorrect sourcemap is generated
"sources": [
"node_modules/@parcel/runtime-browser-hmr/lib/runtime-2c252ac6c9223f3b.js",
"packages/a/src/server.ts",
"server.ts",
"packages/b/src/index.ts",
"index.ts",
"node_modules/@parcel/transformer-js/src/esmodule-helpers.js",
"packages/b/src/same.ts",
"same.ts",
"packages/a/src/same.ts"
],
💁 Possible Solution
A workaround is to not use the the tsc transformer plugin, so remove this
"transformers": {
"*.{ts,tsx}": [
"@parcel/transformer-typescript-tsc"
]
}
but this is not an option for me due to #7425
💻 Code Sample
I've set up a full reproduction of the issue here https://github.com/iSplasher/parcel-sourcemap-bug
🌍 Your Environment
| Software |
Version(s) |
| Parcel |
2.2.1 |
| Node |
16.13.2 |
| npm/Yarn |
3.1.1 |
| Operating System |
Windows 11 |
🐛 bug report
A sourcemap bug occurs when using
You get duplicate entries in the
sourcesfield in the generated.mapfile.Only the subsequent sources that only refer to the filenames are mapped (
server.ts,index.ts,same.ts),but these obviously point nowhere relative to the
sourceRootso they are invalid.Additionally, if two filenames are identical when importing from another package in the mono repo,
their entries get overridden (notice how there is only one
same.ts).You can easily see this if you inspect the sourcemap on https://sourcemap-visualiser.vercel.app/
A
sourcemap-info.jsonfile has already been generated in the repro repo.If you remove the transformer plugin from
.parcelrc, correct sourcemaps are generated.🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
Correct sourcemap gets generated
😯 Current Behavior
An incorrect sourcemap is generated
💁 Possible Solution
A workaround is to not use the the tsc transformer plugin, so remove this
but this is not an option for me due to #7425
💻 Code Sample
I've set up a full reproduction of the issue here https://github.com/iSplasher/parcel-sourcemap-bug
🌍 Your Environment