fix corner cases with import (#4709)

fixes #4708
This commit is contained in:
Alex Lam S.L
2021-02-28 23:13:49 +00:00
committed by GitHub
parent 81254f67e4
commit ec0440f264
4 changed files with 67 additions and 5 deletions

View File

@@ -1127,6 +1127,9 @@ merge(Compressor.prototype, {
def(AST_SymbolCatch, function() {
this.definition().fixed = false;
});
def(AST_SymbolImport, function() {
this.definition().fixed = false;
});
def(AST_SymbolRef, function(tw, descend, compressor) {
var d = this.definition();
push_ref(d, this);
@@ -5836,6 +5839,14 @@ merge(Compressor.prototype, {
assignments.add(def.id, node);
return true;
}
if (node instanceof AST_SymbolImport) {
var def = node.definition();
if (!(def.id in in_use_ids) && (!drop_vars || !is_safe_lexical(def))) {
in_use_ids[def.id] = true;
in_use.push(def);
}
return true;
}
} else if (node instanceof AST_This && scope instanceof AST_DefClass) {
var def = scope.name.definition();
if (!(def.id in in_use_ids)) {