split code into more tokens to fix sourcemap-validator warnings#51
split code into more tokens to fix sourcemap-validator warnings#51connorjclark wants to merge 3 commits intowebpack:masterfrom
Conversation
|
|
| } | ||
| return new SourceNode(null, null, null, | ||
| _splitCode(line + (idx != lines.length - 1 ? "\n" : "")).map(function(item) { | ||
| if(/^\s*$/.test(item)) { |
There was a problem hiding this comment.
This was from my previous attempt: #41. Removed, as it wasn't quite correct.
I think it worked in some cases, but only coincidentally. Possibly it made the first identifier on a line map correctly, and I didn't look further than that while checking it worked?
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
===========================================
- Coverage 78.25% 16.58% -61.67%
===========================================
Files 11 8 -3
Lines 492 416 -76
Branches 76 67 -9
===========================================
- Hits 385 69 -316
- Misses 107 347 +240
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
===========================================
- Coverage 78.25% 16.58% -61.67%
===========================================
Files 11 8 -3
Lines 492 416 -76
Branches 76 67 -9
===========================================
- Hits 385 69 -316
- Misses 107 347 +240
Continue to review full report at Codecov.
|
| var Source = require("./Source"); | ||
|
|
||
| var SPLIT_REGEX = /(?!$)[^\n\r;{}]*[\n\r;{}]*/g; | ||
| var SPLIT_REGEX = /([^\d\w]+)/g; |
There was a problem hiding this comment.
Could you measure how much this affects performance? As far as I remember this could have negative performance impact on larger files.
Fixes webpack/webpack#8302
Add more nodes to create a more granular identity source map. This allows for better source maps when other consumers process what webpack creates (I've been using the terser plugin).
Previous splitting resulted in this (this is post-terser):

note that all mappings map to column 0 for every line.
Now:
I also added a test that did a (too simple) check w/
sourcemap-validator. It passes even w/o these changes - I didn't spend any time thinking about how to create a test case that would mimic what terser was doing. Perhaps someone could help with that?