Bugfix/invalid sourcemaps whitespace#41
Conversation
…ains leading whitespace
| "js-beautify": "^1.5.10", | ||
| "mocha": "^3.4.2", | ||
| "should": "^11.2.1" | ||
| "should": "^11.2.1", |
There was a problem hiding this comment.
Why we need should here?
There was a problem hiding this comment.
Can you elaborate? The tests use should.
lib/ReplaceSource.js
Outdated
| } | ||
|
|
||
| replace(start, end, newValue) { | ||
| replace(start, end, newValue, oldValue = undefined) { |
There was a problem hiding this comment.
I suppose older versions of Node don't support default values. I'll replace this code. Should be fine to just remove it (undefined is the default default ;) ), but I wanted to be explicit.
|
@hoten CI test failed, need fix |
|
Pushed fixes |
Codecov Report
@@ Coverage Diff @@
## master #41 +/- ##
==========================================
+ Coverage 75.04% 75.19% +0.14%
==========================================
Files 11 11
Lines 505 508 +3
Branches 83 83
==========================================
+ Hits 379 382 +3
Misses 126 126
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #41 +/- ##
==========================================
+ Coverage 75.04% 75.53% +0.48%
==========================================
Files 11 11
Lines 505 515 +10
Branches 83 84 +1
==========================================
+ Hits 379 389 +10
Misses 126 126
Continue to review full report at Codecov.
|
lib/ReplaceSource.js
Outdated
| } | ||
|
|
||
| replace(start, end, newValue) { | ||
| replace(start, end, newValue, oldValue) { |
There was a problem hiding this comment.
newValue => replacer || replacement
oldValue => replacee || replaced
(Nitpick)
There was a problem hiding this comment.
@michael-ciniawsky not related to this PR, here bug fix, not refactoring
add name to insert
This handles the case when identifiers are renamed twice
|
Thanks |
|
@hoten did this PR fix the original issue? webpack@4.20.0 uses webpack-sources@1.3.0, but the issue is still reproducible in https://github.com/kenhoff/webpack-sourcemap-testing when webpack version is updated. |
|
Yeah, I'm still seeing the same issue. Side note, your test case isn't as intended. You've locked webpack to |
|
@hoten just in case I've forked the repo and updated webpack version to the latest and changed the scripts https://github.com/adaniliuk/webpack-sourcemap-testing There is the output: cc @sokra |
Would you mind opening a new issue so this doesn't get lost in the closed PR comments? |
|
@edmorley sure, I was going to do that. |
Fixes webpack/webpack#7616
OriginalSource created a source map that failed validation (
sourcemap-validator). Theposvariable tracks the column number for a particular line, but doesn't get incremented when the current token is all whitespace. I believe that only happened for leading whitespace, as all (but possibly the last) token returned by_splitCodewould contain some non-whitespace character. The effect was off-by-some-columns errors in the mappings, which manifested in the bootstrap template for webpack (it has leading whitespace).To create a test, I had to expand the interface for ReplaceSource.replace to get
namespopulated in the source map.