From 7b8118d8bde0d94f8637dbd9f415b78d4575699a Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 11 Feb 2015 00:13:21 +1100 Subject: [PATCH] default newName in scope.rename to a new uid --- lib/6to5/transformation/modules/common.js | 4 +--- lib/6to5/traversal/scope.js | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/6to5/transformation/modules/common.js b/lib/6to5/transformation/modules/common.js index 364aa11626..ed1a3d3262 100644 --- a/lib/6to5/transformation/modules/common.js +++ b/lib/6to5/transformation/modules/common.js @@ -17,9 +17,7 @@ CommonJSFormatter.prototype.init = function () { var file = this.file; var scope = file.scope; - if (scope.hasBinding("module")) { - scope.rename("module", file.generateUidIdentifier("module").name); - } + scope.rename("module"); if (!this.noInteropRequireImport && this.hasNonDefaultExports) { file.ast.program.body.push(util.template("exports-module-declaration", true)); diff --git a/lib/6to5/traversal/scope.js b/lib/6to5/traversal/scope.js index bca6a07407..0731d4ac82 100644 --- a/lib/6to5/traversal/scope.js +++ b/lib/6to5/traversal/scope.js @@ -146,6 +146,8 @@ Scope.prototype.checkBlockScopedCollisions = function (kind, name, id) { }; Scope.prototype.rename = function (oldName, newName) { + newName = newName || this.generateUidIdentifier(oldName).name; + var info = this.getBindingInfo(oldName); if (!info) return;