Fix reused nodes - part 1 (#7149)

This commit is contained in:
Mateusz Burzyński
2018-01-11 19:31:48 +01:00
committed by Nicolò Ribaudo
parent 63ae923987
commit 912bcc186d
30 changed files with 202 additions and 117 deletions

View File

@@ -34,7 +34,7 @@ export default function(api, options) {
path.replaceWith(node.declaration);
path.insertAfter(
t.exportNamedDeclaration(null, [
t.exportSpecifier(ref, t.identifier("default")),
t.exportSpecifier(t.cloneNode(ref), t.identifier("default")),
]),
);
},

View File

@@ -34,7 +34,7 @@ export default class LooseClassTransformer extends VanillaTransformer {
classRef = this._protoAlias;
}
const methodName = t.memberExpression(
classRef,
t.cloneNode(classRef),
node.key,
node.computed || t.isLiteral(node.key),
);

View File

@@ -387,12 +387,12 @@ export default class ClassTransformer {
// special case single arguments spread
bareSuperNode.arguments[1] = bareSuperNode.arguments[1].argument;
bareSuperNode.callee = t.memberExpression(
superRef,
t.cloneNode(superRef),
t.identifier("apply"),
);
} else {
bareSuperNode.callee = t.memberExpression(
superRef,
t.cloneNode(superRef),
t.identifier("call"),
);
}
@@ -456,7 +456,7 @@ export default class ClassTransformer {
const superRef = this.superName || t.identifier("Function");
let thisRef = function() {
const ref = path.scope.generateDeclaredUidIdentifier("this");
thisRef = () => ref;
thisRef = () => t.cloneNode(ref);
return ref;
};