Re-queue remapped imports so they are re-traversed - fixes T6863

This commit is contained in:
Logan Smyth
2016-02-21 23:34:52 -08:00
parent 01003b954a
commit 0a0407be41
4 changed files with 40 additions and 3 deletions

View File

@@ -63,6 +63,7 @@ export default function () {
} else {
path.replaceWith(remap);
}
this.requeueInParent(path);
},
AssignmentExpression(path) {
@@ -86,6 +87,7 @@ export default function () {
}
path.replaceWith(node);
this.requeueInParent(path);
},
UpdateExpression(path) {
@@ -102,7 +104,9 @@ export default function () {
let node = t.assignmentExpression(path.node.operator[0] + "=", arg.node, t.numericLiteral(1));
if ((path.parentPath.isExpressionStatement() && !path.isCompletionRecord()) || path.node.prefix) {
return path.replaceWith(node);
path.replaceWith(node);
this.requeueInParent(path);
return;
}
let nodes = [];
@@ -116,7 +120,8 @@ export default function () {
}
nodes.push(t.binaryExpression(operator, arg.node, t.numericLiteral(1)));
path.replaceWithMultiple(t.sequenceExpression(nodes));
let newPaths = path.replaceWithMultiple(t.sequenceExpression(nodes));
for (const newPath of newPaths) this.requeueInParent(newPath);
}
};
@@ -426,7 +431,12 @@ export default function () {
}
path.unshiftContainer("body", topNodes);
path.traverse(reassignmentVisitor, { remaps, scope, exports });
path.traverse(reassignmentVisitor, {
remaps,
scope,
exports,
requeueInParent: (newPath) => path.requeue(newPath),
});
}
}
}