diff --git a/lib/6to5/transformation/modules/common.js b/lib/6to5/transformation/modules/common.js index 950b35790e..73653c8d04 100644 --- a/lib/6to5/transformation/modules/common.js +++ b/lib/6to5/transformation/modules/common.js @@ -27,7 +27,9 @@ CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes) // import foo from "foo"; if (t.isSpecifierDefault(specifier)) { - var ref = util.template("require", {MODULE_NAME: node.source}); + var ref = util.template("require", { + MODULE_NAME: node.source + }); if (!_.contains(this.file.dynamicImports, node)) { ref = t.callExpression(this.file.addHelper("interop-require"), [ref]); } diff --git a/lib/6to5/transformation/transformers/optional-self-contained.js b/lib/6to5/transformation/transformers/optional-self-contained.js index 0ab0cdbd3a..0fd9eac9f3 100644 --- a/lib/6to5/transformation/transformers/optional-self-contained.js +++ b/lib/6to5/transformation/transformers/optional-self-contained.js @@ -70,9 +70,8 @@ exports.ast = { } }; -exports.MemberExpression = function (node, parent, scope, context, file) { - var obj = node.object; - var prop = node.property; - if (!t.isReferenced(node, parent) || !t.isReferenced(obj, node)) return; - if (obj.name === "regeneratorRuntime") return t.memberExpression(file._regeneratorId, prop); +exports.Identifier = function (node, parent, scope, context, file) { + if (node.name === "regeneratorRuntime" && t.isReferenced(node, parent)) { + node.name = file._regeneratorId; + } };