generate higher quality SourceMaps#109
Merged
alexander-akait merged 3 commits intomasterfrom Jul 31, 2019
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #109 +/- ##
=======================================
Coverage 98.58% 98.58%
=======================================
Files 5 5
Lines 283 283
Branches 113 113
=======================================
Hits 279 279
Misses 4 4
Continue to review full report at Codecov.
|
sokra
commented
Jul 31, 2019
| "error": undefined, | ||
| "extractedComments": Array [], | ||
| "map": "{\\"version\\":3,\\"sources\\":[\\"test1.js\\"],\\"names\\":[\\"foo\\",\\"x\\",\\"not_called1\\"],\\"mappings\\":\\"AAAA,SAASA,IAAIC,GACT,GACIA,EAAA,OACAC\\"}", | ||
| "map": "{\\"version\\":3,\\"sources\\":[\\"test6.js\\"],\\"names\\":[\\"foo\\",\\"x\\",\\"bar\\"],\\"mappings\\":\\"AAAA,SAASA,IAAIC,GAAK,GAAIA,EAAK,OAAOC\\"}", |
Member
Author
There was a problem hiding this comment.
We no longer apply the inputSourceMap in the worker, so this snapshot has changed.
It was incorrect anyway since not_called1 should not be in the SourceMap as it is dropped by terser.
sokra
commented
Jul 31, 2019
| Error: \\"version\\" is a required argument.", | ||
| ] | ||
| `; | ||
| exports[`when options.sourceMap matches snapshot for a single \`true\` value (\`devtool\` is \`source-map\`) and source map invalid: errors 1`] = `Array []`; |
Member
Author
There was a problem hiding this comment.
This no longer crashes, but a warning is still displayed.
e7a6f1d to
d6dcb27
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR contains a:
Motivation / Use-Case
fixes webpack/webpack#8302
Mappings generated when combining bundle source map with terser source map are not very fine, which leads to validation errors and low quality source maps.
There are many causes:
We had a similar problem with webpack replacements (using the
ReplaceSourcefrom webpack-sources) and a good fix turned out to be:Assume that mappings, where generates source and original source are identical for a mapping, map source code char by char.
With this assumption mappings don't have to be super exact as long code stays equal. This allows to apply the high quality terser SourceMap to the lower quality webpack SourceMap without loosing quality.
webpack-sources now implements with kind of assumption (I call it "identity" mappings) for
SourceMapSource. This PR changes terser-webpack-plugin to use it.Test snapshots are updated with new mappings that include more column information.
Breaking Changes
This should have no breaking changes. SourceMaps are very similar, but with additional column information.
Additional Info
For reviewing see only second commit. First commit changes snapshot format to be easier reviewable.