fix(sourcemap): accept a sourceMappingURL that ends with a newline#45983
Merged
Conversation
weswigham
requested changes
Sep 27, 2021
|
|
||
| // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) | ||
| const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; | ||
| const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\n?$/; |
Member
There was a problem hiding this comment.
Also include \r?, just in case~
weswigham
reviewed
Oct 1, 2021
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.
Fixes #45982
After I upgraded my TypeScript I noticed my sourcemaps broke. I bisected down to #44197, which
seem to subtly change the regex matching the sourceMappingURL so that it will not match
if the line ends with '\n'.
The old regex ended with
\s*to match and trim all whitespace.The new regex doesn't have that I guess for performance? But because
.does not match\n, andgetLineText preserves the ending
\n, this does not match any line that isn't the last one in thefile.
I am happy to add a test if someone points me to the correct place for it. I tried to add
a fourslash test but I couldn't seem to create a file where the last line was a newline.