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
fix(sourcemap): fall back to low-resolution line mapping #4334
Conversation
…inside `Link.traceSegment` instead of returning null, so that a low-resolution sourcemap preceding a high-resolution sourcemap in the sourcemap chain doesn't fail.
f9c808b
to
ac2e525
Compare
Codecov Report
@@ Coverage Diff @@
## master #4334 +/- ##
==========================================
+ Coverage 98.75% 98.76% +0.01%
==========================================
Files 204 204
Lines 7308 7309 +1
Branches 2080 2077 -3
==========================================
+ Hits 7217 7219 +2
Misses 33 33
+ Partials 58 57 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much.
I'm not sure if unit testing this change is necessary.
A test would really go a long way here, especially to document the case you are fixing. Currently I can only guess from your comments what the scenario is you are fixing, with a test we would actually know.
Also, if we ever start introducing WebAssembly parts into Rollup, source map handling would be the first candidate to be rewritten, in which case we really need this test to avoid regressions.
Just added a similar fix to I've no time to write tests for a fix that I know works, unfortunately. |
That is very unfortunate. You could tell us at least what plugins cause the issue so that someone else can add a test, or how these source maps are generated. That is, if you want to get rid of your fork. |
dc0d52d
to
a25b540
Compare
Now that I think I understand the issue I added some tests and changed the logic: Instead of adding a special case for mappings with a single mapping per line, the logic will now handle general cases of lower resolution sourcemaps by using the closest matching column if no exact match can be found, following the principle that an imprecise source map is still more helpful than none at all. |
f7cd316
to
4041d4c
Compare
I believe your changes will work for me, thanks! |
@aleclarson Looks like you just made rollup sourcemaps twice bigger |
Ok, I'm just pointing fingers 😄 |
Maybe they are also twice as good now? |
Probably 😄 Vite doesn't publish sourcemaps to NPM anymore, perhaps Rollup should do the same? The rationale is that people who need sourcemaps can clone the repository easily enough. And of course, it means less disk usage and (most importantly?) faster downloads. As far as reducing the size of sourcemaps generated by Rollup, you could add a low-resolution option, which only maps lines instead of columns. I don't personally share the concern about fat sourcemaps, but it would certainly be appreciated by those who do. |
We are only publishing the source map for the browser build, and the reason is that this allows people to use the REPL for debugging Rollup itself. This was done on request by the people from replay who are using Rollup as some kind of example: https://app.replay.io/recording/rollupjs--fce3ed6c-091b-4c0d-95a5-33f35965986c?point=1622592768338673616292244694761494&time=1797&hasFrames=false Nevertheless, this was already critizised by others and the plan is to move the browser build to a separate artifact with the next major version. So the problem with the current sourcemaps is likely that most generated code fragments are now mapped to the closest source position in the same line instead of having no mappings. This will likely improve debugging in some cases, but otherwise just takes up a lot of space. |
Maybe we should go with Alec's solution after all, it will only blow up the source map if one plugin uses a low-resolution source map 😅 |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
Basically, segment tracing was failing when a high-resolution sourcemap (which is column sensitive) comes after a low-resolution sourcemap (whose segments only have line information). This led to the related source file being excluded from the collapsed sourcemap, which is bad.
I'm not sure if unit testing this change is necessary. I've tested it manually in my project, and it works great!