From a4659fd239c0aac273787e197c4d400d3a6fd59d Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 6 Mar 2015 23:19:26 +1100 Subject: [PATCH] add reference checks for module specifiers - fixes #956 --- src/babel/types/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/babel/types/index.js b/src/babel/types/index.js index cfa4dea0e5..b29e417286 100644 --- a/src/babel/types/index.js +++ b/src/babel/types/index.js @@ -295,6 +295,16 @@ t.isReferenced = function (node, parent) { return parent.id !== node; } + // no: export { foo as NODE }; + if (t.isExportSpecifier(parent, { name: node })) { + return false; + } + + // no: import { NODE as foo } from "foo"; + if (t.isImportSpecifier(parent, { id: node })) { + return false; + } + // no: class NODE {} if (t.isClass(parent)) { return parent.id !== node;