Update source map handling to be reentrant
Rather than repeating the original location when we exit a node, we need to restore the previous parent’s original line location, since the source map format denotes the start location.
This commit is contained in:
@@ -46,7 +46,7 @@ export default class Printer extends Buffer {
|
||||
|
||||
if (opts.before) opts.before();
|
||||
|
||||
this.map.mark(node, "start");
|
||||
this.map.mark(node);
|
||||
|
||||
this._print(node, parent);
|
||||
|
||||
@@ -58,7 +58,7 @@ export default class Printer extends Buffer {
|
||||
if (needsParens) this.push(")");
|
||||
|
||||
// end
|
||||
this.map.mark(node, "end");
|
||||
if (parent) this.map.mark(parent);
|
||||
if (opts.after) opts.after();
|
||||
|
||||
this.format.concise = oldConcise;
|
||||
|
||||
@@ -40,7 +40,7 @@ export default class SourceMap {
|
||||
* Mark a node's generated position, and add it to the sourcemap.
|
||||
*/
|
||||
|
||||
mark(node, type) {
|
||||
mark(node) {
|
||||
let loc = node.loc;
|
||||
if (!loc) return; // no location info
|
||||
|
||||
@@ -56,7 +56,7 @@ export default class SourceMap {
|
||||
column: position.column
|
||||
};
|
||||
|
||||
let original = loc[type];
|
||||
let original = loc.start;
|
||||
|
||||
// Avoid emitting duplicates on either side. Duplicated
|
||||
// original values creates unnecesssarily large source maps
|
||||
|
||||
Reference in New Issue
Block a user