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
inline sourcemaps and cache API cause incorrect sourcemap output #3465
Comments
Here are a few tests reproducing it: jbedard@5765190 |
Note this also happens when using |
Your test does not appear to use the cache API, am I missing something here? So one thing to note is that Rollup does NOT pick up inlined or external sourcemaps by default to merge them into the final sourcemap. If you want something like this, you may want e.g. https://github.com/maxdavidson/rollup-plugin-sourcemaps Beyond that it sounds like your actual problem is that the inline sourcemap is not removed and thus causes issues, is that correct? |
But I can definitely confirm that the sourcemap is only removed on the first run and not on the second, so it appears the existing logic to remove sourcemaps is not triggered when using the cache. We definitely need to fix this! |
Every test in the |
Ah, nicely spotted! |
Tentative fix at #3476 |
Thanks! Worth adding jbedard@5765190 as well? |
Sure, will try to merge it |
The test description is wrong, though, as the inline sourcemaps are not combined. They are just removed. See my comment above. |
And we will need to switch to asserts that work in Node 10... |
I'm confused... the tests are outputting sourcemaps though (there are .js.map files in the |
Yes it does. But the sourcemaps only take Rollup's transformations + any plugin transformations into account. Pre-existing sourcemaps are ignored by default — unless you add a plugin that changes that. The reasoning is that developers are usually only interested in sourcemaps for their own code, and plugins take care of that. Pre-existing sourcemaps usually come with third-party libraries where you are usually not that interested in detailed original code locations, especially if you do not have this code available anyway. Also, obeying pre-existing sourcemaps comes at a performance cost. |
I removed the test about external sourcemaps because it really does not test anything interesting IMO, and change the description and asserts of the other test. |
I see, thanks! This look right? jbedard@3e18939 |
Yes. But the two tests now basically test the same thing, so I would remove one. |
I figured it was worth testing inline + external. I had to test both to know if it effected both 🤷♂ I can remove one if you prefer that though. Remove the inline one because a giant blob of base64 is ugly..? |
Well, only inline sourcemaps are a problem. External sourcemaps are not touched at all. |
But the sourcemap comment should be removed either way... |
Ah true, there is still a comment. Makes sense. |
Reproduction (can create a git repo if wanted, but this is pretty simple):
Given the following inputs:
index.js
other.js (compiled from a ts file that used
const
and hadx: string
)Then run rollup via the API twice, the second time with the cache of the first. This is essentially the same as https://rollupjs.org/guide/en/#cache
Expected Behavior
The same output each time (a single
.js.map
file alongside the bundle). Hopefully the cache makes it faster.Actual Behavior
The
//# sourceMappingURL=data:
correctly gets merged into the outputtedrun-1.js.map
on the first run. Then it remains within the code (run-2.js
) on the second run (andrun-2.js.map
is a tiny amount larger then the first run, so it's probably still merged into there).The text was updated successfully, but these errors were encountered: