parcel: V2: inline source maps are malformed
๐ bug report
When inspecting TS files generated with inline source maps in chrome debugger - the mapping turns out to be absolutely wrong.
๐ Configuration (.babelrc, package.json, cli command)
.parcelrc:
{
"extends": "@parcel/config-default",
"transformers": {
"*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
}
}
package.json
"targets": {
"default": {
"sourceMap": {
"inline": true,
"inlineSources": true
}
}
},
๐ค Expected Behavior
Chrome Debugger Sources panel works as intented.
๐ฏ Current Behavior
Ignore code meaning; pay attention to line numbers
One thing: I cannot set breakpoints in valid places; you can see that many lines are greyed out: 44, 48, 51. If I put a breakpoint on line 47, for example, - it would break execution on some absolutely different part of code than line 47!
Second thing: line 44 - console.log(123);. It references absolutely different line number when printing to console:

๐ Possible Solution
๐ฆ Context
This is the background script of chrome extn.
๐ป Code Sample
๐ Your Environment
| Software | Version(s) |
|---|---|
| Parcel | ^2.0.0-nightly.574 |
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 21 (10 by maintainers)
Actually, this workaround isnt applicable to
parcel serve- since there is no--no-scope-hoistoption. (I have this bug in development as well)Just wanted to add that I have this same issue with
parcel serveas well. In addition to having incorrect line numbers, there seems to be a variable scoping issue of some sort making the chrome debugger behave real awkward to use. Iโve had cases like this one where within the same function I haditem3 times with different values making it impossible to debug.(This isnโt specific to inline sourcemaps)
https://github.com/parcel-bundler/parcel/tree/5815-ts-sourcemap seems to fix it for
--no-scope-hoist(= and development). But the maps with scope-hoisting is still broken as before.@mischnic
After some heavy debugging I figured out. If you are using Template literals (``) the source map is completely broken.
index.ts
index.html
Devtools
I have the same issue โavalanche1โ posted on Feb 10 - โI cannot set breakpoints in valid places; you can see that many lines are greyed out. If I put a breakpoint on non-grayed out lines, it would break execution on some absolutely different part of code!โ
I am using parcel 2.0.1 (the latest version of parcel 2) to build a react application with typescript, and started the application by running โparcel serve index.htmlโ. I tried to install parcel@2.0.0-nightly.574, but when running parcel build, it would automatically install @parcel/transformer-typescript-tsc@2.0.1, which then complains a unmatched version with parcel@2.0.0-nightly.574.
So in summary, debug typescript source code with source map doesnโt work with parcel 2.0.1. Could you please help on this? Thanks.
I can confirm that the nightly solved the problem.