Repository navigation
Runtime plugins: positions go through the inline source map of what onLoad returned
#46148
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
Open
dylan-conway
wants to merge
9
commits into
main
Choose a base branch
from
claude/plugin-input-source-map
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+646
−30
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eda5c46
Positions in a file that a runtime plugin rewrote go through the inli…
dylan-conway c12bf89
Read a plugin's inline source map in the module loader, and give the …
dylan-conway cb1c3a2
Code that a plugin's source map does not cover keeps its position and…
dylan-conway 79d46ce
Coverage of a bundle of several files counts every source again, a st…
dylan-conway 0508569
A position between two mappings of a plugin's source map keeps its di…
dylan-conway 77d8cb3
Coverage reports a file that was built earlier in its own lines inste…
dylan-conway 94b6871
Coverage keeps reading a map whose only source is the file itself, so…
dylan-conway 485abb2
A map that the file on disk ends with too is not taken from what a pl…
dylan-conway 205d091
Merge commit '9b4284f788f20e3d6ec8358daf62ad10694b158a' into claude/p…
dylan-conway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🟡 (optional) Plugin users whose compiler marks generated code with 1-field segments (Babel, anything built on
source-map/gen-mapping) get that code reported at a made-up position in their file instead of left out. The map parser drops 1-field segments (src/sourcemap/Mapping.rs:556-562), sofind_mappingat src/sourcemap/Chunk.rs:619 returns the preceding original segment for generated text that follows it on the same line, and the projection at Chunk.rs:627 attributes it to the file with source index 0. Fix: treat a 1-field segment as ending the previous segment's range, e.g. keep it in the list with a no-source marker thatfind_mappingreports as uncovered, so theNOT_IN_INPUT_SOURCE_MAPbranch fires for it and coverage skips it.Why this was flagged
A runtime
onLoadplugin returns Babel orsource-map-generated output ending in an inline map whose single source is the file; such maps mark synthesized code with 1-field segments, which per the source map spec mean "no original position" and end the previous segment's range.Mapping::parseat src/sourcemap/Mapping.rs:556-562 discards every 1-field segment.append_mappingat src/sourcemap/Chunk.rs:619-622 then callsfind_mapping, which (Mapping.rs:156-171) returns the last mapping on the same generated line with column <= the token's column, i.e. the original segment that the dropped terminator was supposed to close. The token gets source_index 0 at Chunk.rs:623 and a column oforig_col + (col - seg_col)at Chunk.rs:627-628, often past the end of the original line. A throw inside such trailing generated code is reported asfile.ts:L:Cwith a column that does not exist, andbun test --coveragecounts that offset against original line L viacount_line(src/sourcemap_jsc/CodeCoverage.rs:739) instead of skipping it throughis_added_to_the_file(CodeCoverage.rs:722). On the base branch no remapping happened at all.Verification: The scalar parser discards 1-field segments:
src/sourcemap/Mapping.rs:556-573.find_index_from_generated(src/sourcemap/Mapping.rs:150-173) returnsindex-1whenever that row is on the same generated line. The newappend_mapping(src/sourcemap/Chunk.rs:617-631) then setssource_index = 0and a fabricated column, and only takes theNOT_IN_INPUT_SOURCE_MAPbranch whenfind_mappingreturnsNone.