Repository navigation
Flatten index sourcemaps returned by plugins - #6601
Conversation
|
@wleeaf is attempting to deploy a commit to the rollup-js Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install wleeaf/rollup#sourcemap-index-mapsNotice: To build the native dependencies, you need Rustup installed; the required nightly toolchain is then picked up automatically from |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Performance report
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6601 +/- ##
==========================================
+ Coverage 98.30% 98.31% +0.01%
==========================================
Files 380 380
Lines 13985 14034 +49
Branches 2978 2991 +13
==========================================
+ Hits 13748 13798 +50
Misses 194 194
+ Partials 43 42 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lukastaegert
left a comment
There was a problem hiding this comment.
One thing to consider is that currently, index source maps are not accepted in the user-facing types in rollup.d.ts. If we are to support them, maybe we should add them?
E.g.
export type SourceMapInput = ExistingRawSourceMap | IndexSourceMap | string | null | { mappings: '' };
export interface IndexSourceMap {
file?: string | undefined;
sections: {
map: ExistingRawSourceMap | IndexSourceMap;
offset: { column: number; line: number };
}[];
version: number;
}names is optional in a source map, so an embedded map without it must not abort the build.
Typed plugins can now return an index map from load, transform and renderChunk without a cast.
|
Added in 307673d with your The Copilot finding about The new Once both PRs are in, the casts in |
lukastaegert
left a comment
There was a problem hiding this comment.
Changes look good!
Once both PRs are in, the casts in flattenIndexSourceMap that work around the old sources type are no longer needed; whichever PR is merged second can drop them.
As the other PR is merged, this is not unlocked I suppose?
|
Yes. I'm merging |
|
This PR has been released as part of rollup@4.66.0. You can test it via |


This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
ECMA-426 defines index source maps as an alternative to regular maps. They have no
mappingsfield. Instead,sectionslists embedded regular maps, each with the generatedoffsetit starts at. When aload,transformorrenderChunkhook returns one,decodedSourcemapfinds nomappingsand replaces it with an empty map, so every mapping of that module is dropped without a warning.decodedSourcemapnow flattens these maps the way the spec's DecodeIndexSourceMap does:offset. The column offset only applies to the section's first line.sourceRootis applied to its sources, because an embedded map "does not inherit any values from the containing index map". An absolute source is left as is, as for regular maps.transformmaps, where only the first source stands for the previous code.SourceMapInputnow includes index maps, so typed plugins can return them without a cast. An embedded map may omitnames.Regular maps only pay for an extra
'sections' in mapcheck. The newindex-sourcemapssample covers aloadmap and atransformmap. It fails on master because the output map has no sources.generated with AI