diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-16 13:22:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-16 13:22:26 +0800 |
commit | 5ae04b35452693e886a7f836e62e3290b08016a1 (patch) | |
tree | 3d96ec1d04b055d219630d6cc580c443691b54b1 /lib | |
parent | a80b228d8be37eb6585bca01c6fb5468db5bea42 (diff) | |
download | tracifyjs-5ae04b35452693e886a7f836e62e3290b08016a1.tar.gz tracifyjs-5ae04b35452693e886a7f836e62e3290b08016a1.zip |
make `collapse_vars` consistent with `toplevel` (#1608)
fixes #1605
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 49b618e7..dac1f364 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -521,6 +521,7 @@ merge(Compressor.prototype, { var self = compressor.self(); var var_defs_removed = false; + var toplevel = compressor.option("toplevel"); for (var stat_index = statements.length; --stat_index >= 0;) { var stat = statements[stat_index]; if (stat instanceof AST_Definitions) continue; @@ -558,7 +559,8 @@ merge(Compressor.prototype, { // Only interested in cases with just one reference to the variable. var def = self.find_variable && self.find_variable(var_name); - if (!def || !def.references || def.references.length !== 1 || var_name == "arguments") { + if (!def || !def.references || def.references.length !== 1 + || var_name == "arguments" || (!toplevel && def.global)) { side_effects_encountered = true; continue; } |