-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
source mappings of dropped code are emitted and conflict with retained code #3001
Comments
Interesting. I would assume this is actually not an issue within Rollup itself but in magic-string, which is generating the sourcemaps based on knowledge of all code modifications. |
//cc @mourner if you have a little more insight into magic-strings internals, many recent commits were done by you. |
The problem first appears in
The problem does not occur with In any case, the net effect is still a bug in core rollup. Other projects use labels like |
@Rich-Harris - any thoughts? |
Tentative magic-string fix for this rollup bug: Rich-Harris/magic-string#159 |
To see how this issue negatively impacts debugging after tree shaking, here's the rollup generated source maps in a visualizer: rollup v1.17.0 without magic-string fix rollup v1.17.0 with magic-string fix Click on the |
Fixes #149 Also fixes two incorrect test results and the rollup issue: rollup/rollup#3001
magic-string@0.25.5 was just released with a number of fixes including the one pertinent to this issue. Because magic-string is inlined into the Rollup bundle, users will have to wait until Rollup dependencies are updated and a new release is made. Be aware that upgrading to the new version of magic-string will likely alter every sourcemap checked into the rollup tree. Closing issue. |
Thanks for the tip, I created #3318 to update the dependency |
The source map fix in Rich-Harris/magic-string#159 wasn't general enough. It only applied to the first source file. Here's a test case demonstrating incorrect mappings with latest rollup:
Here's the bug viewed with sourcemap visualizer Still more bugs are evident when the magic-string fix in the works. |
Confirmed that magic-string PR Rich-Harris/magic-string#173 fixes this multi-source bundle mapping bug. Once merged and magic-string released expect to update most source maps in the rollup tree once again. |
The magic-string PR in question was merged. Once a release is made Rollup can update its deps. Closing out issue. |
Thanks for your work on this |
@lukastaegert Happy to help out. Do you plan to use non-released magic-string commits and/or PRs in a future Rollup release, or is this just for your own local testing? Side note - I'm surprised that Rollup users didn't notice the rather obvious source map bugs. It appears that fewer users actually do source map debugging than I thought. |
I wanted to but it turned out that |
Might have to wait a few months for a release. If @lukastaegert You might consider creating a |
Nah, I'll just nag people. |
How Do We Reproduce?
Expected Behavior
Source mappings of dropped code should not be emitted.
Actual Behavior
Source mappings of dropped code are emitted:
which collide with these correctly generated mappings of retained code:
Encountered this bug when looking at #2996.
The text was updated successfully, but these errors were encountered: