-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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: Properly generate source maps for manually added multi-line content #15365
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53787/ |
@@ -371,7 +371,7 @@ async function run(task: Test) { | |||
} | |||
} | |||
|
|||
if (opts.sourceMaps === true) { | |||
if (opts.sourceMaps === true || opts.sourceMap === true) { |
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.
sourceMaps
vs sourceMap
is confusing. I would prefer we stick to one of them in the test runner.
if (last < len) { | ||
this._mark(++line, 0, identifierName, filename); | ||
this._mark( | ||
// When manually adding multi-line content (such as a comment), `line` will be `undefined`. | ||
line != undefined ? ++line : line, | ||
0, | ||
identifierName, | ||
filename, | ||
); |
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.
If this is a source-less segment (it doesn't have an original line/column), then we only need to call mark 0/1 times (which is done above the loop). That's because any additional lines generated by the comment will also be source-less, and source-less segments at the beginning of a line are discarded by gen-mapping
.
if (last < len) { | |
this._mark(++line, 0, identifierName, filename); | |
this._mark( | |
// When manually adding multi-line content (such as a comment), `line` will be `undefined`. | |
line != undefined ? ++line : line, | |
0, | |
identifierName, | |
filename, | |
); | |
if (last < len && line !== undefined) { | |
this._mark(++line, 0, identifierName, filename); |
This was technically a regression, about a year ago (7.17.0~7.18.0).
A lot of snapshot changes have nothing to do with this fix, it seems like I accidentally broke some tests in a past PR and now they are fixed.