aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 0e698804..101fdb4e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -940,6 +940,8 @@ merge(Compressor.prototype, {
});
if (!node.name) return;
var d = node.name.definition();
+ var parent = tw.parent();
+ if (parent instanceof AST_ExportDeclaration || parent instanceof AST_ExportDefault) d.single_use = false;
if (safe_to_assign(tw, d, true)) {
mark(tw, d);
tw.loop_ids[d.id] = tw.in_loop;
@@ -6709,6 +6711,7 @@ merge(Compressor.prototype, {
var var_decl = 0;
self.walk(new TreeWalker(function(node) {
if (var_decl > 1) return true;
+ if (node instanceof AST_ExportDeclaration) return true;
if (node instanceof AST_Scope && node !== self) return true;
if (node instanceof AST_Var) {
var_decl++;
@@ -6728,12 +6731,15 @@ merge(Compressor.prototype, {
dirs.push(node);
return make_node(AST_EmptyStatement, node);
}
- if (hoist_funs && node instanceof AST_Defun
- && (tt.parent() === self || !compressor.has_directive("use strict"))) {
+ if (node instanceof AST_Defun) {
+ if (!hoist_funs) return node;
+ if (tt.parent() !== self && compressor.has_directive("use strict")) return node;
hoisted.push(node);
return make_node(AST_EmptyStatement, node);
}
- if (hoist_vars && node instanceof AST_Var) {
+ if (node instanceof AST_Var) {
+ if (!hoist_vars) return node;
+ if (tt.parent() instanceof AST_ExportDeclaration) return node;
if (!all(node.definitions, function(defn) {
var sym = defn.name;
return sym instanceof AST_SymbolVar