fix: Properly generate source maps for manually added multi-line content#15365
Merged
nicolo-ribaudo merged 2 commits intobabel:mainfrom Jan 25, 2023
Merged
fix: Properly generate source maps for manually added multi-line content#15365nicolo-ribaudo merged 2 commits intobabel:mainfrom
nicolo-ribaudo merged 2 commits intobabel:mainfrom
Conversation
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53787/ |
JLHwung
reviewed
Jan 25, 2023
| } | ||
|
|
||
| if (opts.sourceMaps === true) { | ||
| if (opts.sourceMaps === true || opts.sourceMap === true) { |
Contributor
There was a problem hiding this comment.
sourceMaps vs sourceMap is confusing. I would prefer we stick to one of them in the test runner.
jridgewell
approved these changes
Jan 25, 2023
Comment on lines
+264
to
+271
| 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, | ||
| ); |
Member
There was a problem hiding this comment.
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.
Suggested change
| 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); |
nicolo-ribaudo
approved these changes
Jan 25, 2023
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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.