diff --git a/src/babel/transformation/transformers/es6/constants.js b/src/babel/transformation/transformers/es6/constants.js index 4a4e5c95d2..8cc5a786f1 100644 --- a/src/babel/transformation/transformers/es6/constants.js +++ b/src/babel/transformation/transformers/es6/constants.js @@ -2,7 +2,7 @@ import * as messages from "../../../messages"; import * as t from "../../../types"; export function check(node) { - return t.isVariableDeclaration(node, { kind: "const" }); + return t.isVariableDeclaration(node, { kind: "const" }) || t.isImportDeclaration(node); } var visitor = { @@ -38,7 +38,7 @@ var visitor = { export function Scopable(node, parent, scope, file) { this.traverse(visitor, { - constants: scope.getAllBindingsOfKind("const"), + constants: scope.getAllBindingsOfKind("const", "module"), file: file }); } diff --git a/src/babel/traversal/scope.js b/src/babel/traversal/scope.js index 9cc73182e2..24a3d8cb40 100644 --- a/src/babel/traversal/scope.js +++ b/src/babel/traversal/scope.js @@ -551,17 +551,20 @@ export default class Scope { * Walks the scope tree and gathers all declarations of `kind`. */ - getAllBindingsOfKind(kind: string): Object { + getAllBindingsOfKind(): Object { var ids = object(); - var scope = this; - do { - for (var name in scope.bindings) { - var binding = scope.bindings[name]; - if (binding.kind === kind) ids[name] = binding; - } - scope = scope.parent; - } while (scope); + for (let i = 0; i < arguments.length; i++) { + var kind = arguments[i]; + var scope = this; + do { + for (var name in scope.bindings) { + var binding = scope.bindings[name]; + if (binding.kind === kind) ids[name] = binding; + } + scope = scope.parent; + } while (scope); + } return ids; }