fix corner cases with export (#4743)

fixes #4742
This commit is contained in:
Alex Lam S.L
2021-03-06 14:49:39 +00:00
committed by GitHub
parent 83c3838b07
commit ad903e9240
3 changed files with 70 additions and 5 deletions

View File

@@ -3425,6 +3425,7 @@ merge(Compressor.prototype, {
if (parent instanceof AST_For && parent.init === node) return null;
return in_list ? List.skip : make_node(AST_EmptyStatement, node);
}
if (node instanceof AST_ExportDeclaration) return node;
if (node instanceof AST_Scope) return node;
if (!is_statement(node)) return node;
}));
@@ -6167,7 +6168,9 @@ merge(Compressor.prototype, {
}
var old_def;
if (!value && !(node instanceof AST_Let)) {
if (drop_sym && var_defs[sym.id] > 1) {
if (parent instanceof AST_ExportDeclaration) {
flush();
} else if (drop_sym && var_defs[sym.id] > 1) {
AST_Node.info("Dropping declaration of variable {name} [{file}:{line},{col}]", template(def.name));
var_defs[sym.id]--;
sym.eliminated++;