Skip to content

Commit

Permalink
fix corner case in unused (#4767)
Browse files Browse the repository at this point in the history
fixes #4766
  • Loading branch information
alexlamsl committed Mar 13, 2021
1 parent 3b5d501 commit 6f3ab09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/compress.js
Expand Up @@ -6216,7 +6216,10 @@ merge(Compressor.prototype, {
});
body.push(defun);
} else {
if (drop_sym && var_defs[sym.id] > 1 && sym.orig.indexOf(def.name) > sym.eliminated) {
if (drop_sym
&& var_defs[sym.id] > 1
&& !(parent instanceof AST_ExportDeclaration)
&& sym.orig.indexOf(def.name) > sym.eliminated) {
var_defs[sym.id]--;
duplicated++;
}
Expand Down
14 changes: 14 additions & 0 deletions test/compress/exports.js
Expand Up @@ -464,3 +464,17 @@ issue_4761: {
}
expect_exact: 'export default"function"==42;'
}

issue_4766: {
options = {
unused: true,
}
input: {
var a = "foo";
export var a = "bar";
}
expect: {
var a = "foo";
export var a = "bar";
}
}

0 comments on commit 6f3ab09

Please sign in to comment.