aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js5
-rw-r--r--test/compress/exports.js14
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index e56ab43b..31e89ab4 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -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++;
}
diff --git a/test/compress/exports.js b/test/compress/exports.js
index 33059bca..0fdf6412 100644
--- a/test/compress/exports.js
+++ b/test/compress/exports.js
@@ -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";
+ }
+}