-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
🐛 bug report: parcel does not load existing sourcemaps of pre-transformed JS assets #741
Comments
Basically we need something like https://github.com/webpack-contrib/source-map-loader |
I've just come across this same issue today when trying to use mapbox-gl & parcel together. |
This seems easy enough to do. We already have the infrastructure in place, just need to parse the existing source map url comment in the code and load it. |
Tried parcel, was delighted, then put a "debugger" statement... Please fix this! |
I agree. What can I do about it? |
What does |
@lxe think about it... [edit] using "debugger" make the source map issue apparent by showing code mismatched to where the debugger clause is. |
any updates? |
any updates ? |
Any insight into how to debug issues where parcel fails to load existing sourcemaps. Similar problem with this npm module: https://github.com/mfbx9da4/deep-email-validator |
I am willing to re-open this issue as I have come across this problem earlier today, and after taking a look at #1349 I understood where the problem is. #1349 did not entirely solve this issue, below is an explanation as to why. From the source code of #1349, in file const SOURCEMAP_RE = /\/\/\s*[@#]\s*sourceMappingURL\s*=\s*([^\s]+)/; Then later, line 114: let match = this.contents.match(SOURCEMAP_RE); This would work fine if all o&&btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")) Uh-oh, looks like folks at neovis.js felt like using multiline comments ( After looking at the source code of parcel v2, it seems that the regexp has been corrected since v1. In file export const SOURCEMAP_RE: RegExp = /(?:\/\*|\/\/)\s*[@#]\s*sourceMappingURL\s*=\s*([^\s*]+)(?:\s*\*\/)?\s*$/; It remains a problem as installing parcel with a simple I think this could be solved by simply copying the regexp from v2 to the v1 source code, should I file a pull request with the changes? |
Hi all, I'm running into this now (parcel version 1.12.5), with a js library called Vexflow. It has the same commenting style noted above:
@lemraus I'm happy to create and submit this PR with your suggested regex above, but I don't see an obvious v1 branch or tag to work off of. @devongovett - any suggestions? Thanks! edit: actually, it might be trickier than I expected. My
and got Earlier in the code, it's doing
which is outputting
So the regex may be off, at least for this particular case. |
This is a 🐛 bug report
General summary:
Importing/requiring a pre-built file does not load its sourcemaps.
For example,
mapbox-gl-js
exports a pre-packagedmain
which lives innode_modules/mapbox-gl/dist/mapbox-gl.js
. It also contains asourceMappingUrl
//# sourceMappingURL=mapbox-gl.js.map
. There is amapbox-gl.js.map
indist/
as well.When doing
import mapboxgl from 'mapbox-gl'
, parcel correctly bundles node_modules/mapbox-gl/dist/mapbox-gl.js, but does not load and re-process its sourcemap.I haven't gotten far with debugging it, but it seems that that file does not satisfy any of the conditions that would mark it for transformation (https://github.com/parcel-bundler/parcel/blob/master/src/transforms/babel.js#L29).
Artificially marking it for a transform (by hardcoding something like
if (/mapbox-gl\.js/.test(asset.name)) return true
will run the babel compiler on it, which is also not what we want.To reproduce:
Inspect the entrypoint:
Inspect the presence of the entrypoint and the map:
Looks like we're pointing to the sourcemap correctly:
Import the file, and package it with parcel:
Verify that the sourcemap of mapbox-gl.js does not get repackaged:
🌍 Your Environment
The text was updated successfully, but these errors were encountered: