Mangling externally imported names by using aliasing

This commit is contained in:
Fábio Santos
2016-02-27 12:01:16 +00:00
committed by Richard van Velzen
parent 59e1601fb8
commit 86b5248837
5 changed files with 44 additions and 2 deletions

View File

@@ -171,6 +171,9 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
else if (node instanceof AST_SymbolClass) {
defun.def_variable(node);
}
else if (node instanceof AST_SymbolImport) {
scope.def_variable(node);
}
else if (node instanceof AST_SymbolDefClass) {
// This deals with the name of the class being available
// inside the class.
@@ -302,6 +305,12 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol){
this.variables.set(symbol.name, def);
def.object_destructuring_arg = symbol.object_destructuring_arg;
def.global = !this.parent_scope;
if (symbol instanceof AST_SymbolImport) {
// Imports are not global
def.global = false;
// TODO The real fix comes with block scoping being first class in uglifyJS,
// enabling import definitions to behave like module-level let declarations
}
} else {
def = this.variables.get(symbol.name);
def.orig.push(symbol);