You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat bug.js
const MagicString = require('./dist/magic-string.umd.js')
const SourceMapConsumer = require( 'source-map' ).SourceMapConsumer;
const s1 = 'ABCDE';
const ms1 = new MagicString(s1, { filename: 'first' });
const s2 = 'VWXYZ';
const ms2 = new MagicString(s2, { filename: 'second' });
const bundle = new MagicString.Bundle();
bundle.addSource(ms1);
bundle.addSource(ms2);
ms1.remove(1,4); // AE
ms1.move(0, 1, 5); // EA
ms2.remove(2,4); // VWZ
ms2.move(0, 1, 5); // WZV
const map = bundle.generateMap({file: 'result', hires: true, includeContent: true});
const smc = new SourceMapConsumer(map);
let output = '';
output += bundle.toString() + '\n';;
const result1 = ms1.toString();
const result2 = ms2.toString();
var line = 1;
for (let i = 0; i < result1.length; i++) {
let loc = smc.originalPositionFor({ line: line, column: i });
output += `${s1[loc.column]} = ${result1[i]}\n`;
}
var line = 2;
for (let i = 0; i < result2.length; i++) {
let loc = smc.originalPositionFor({ line: line, column: i });
output += `${s2[loc.column]} = ${result2[i]}\n`;
}
output += map.toString();
console.log(output);
Incorrect result:
$ cat bug.js | node
EA
WZV
E = E
A = A
W = W
X = Z
V = V
{"version":3,"file":"result","sources":["first","second"],"sourcesContent":["ABCDE","VWXYZ"],"names":[],"mappings":"AAAI,CAAJ;ACAC,CAAC,AAAE,CAAJ"}
$ cat bug.js | node
EA
WZV
E = E
A = A
W = W
Z = Z
V = V
{"version":3,"file":"result","sources":["first","second"],"sourcesContent":["ABCDE","VWXYZ"],"names":[],"mappings":"AAAI,CAAJ;ACAC,CAAG,CAAJ"}
The text was updated successfully, but these errors were encountered:
The fix in #159 wasn't general enough - see rollup/rollup#3001 (comment).
Using
[email protected]
:Incorrect result:
Here's the fix:
Correct result with fix:
The text was updated successfully, but these errors were encountered: