aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-07 03:11:03 +0800
committerGitHub <noreply@github.com>2017-03-07 03:11:03 +0800
commitd787d70127af1b8df57eee2274c720d34092aef2 (patch)
treef95114de6109d4697a6a23244f90117f48c1320f /lib/compress.js
parent3ac24219322384539caae803482ea257e7971cf2 (diff)
downloadtracifyjs-d787d70127af1b8df57eee2274c720d34092aef2.tar.gz
tracifyjs-d787d70127af1b8df57eee2274c720d34092aef2.zip
avoid substitution of global variables (#1557)
- unless `toplevel` is enabled - global `const` works as before
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 8c3fb155..696e2056 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -223,6 +223,7 @@ merge(Compressor.prototype, {
AST_Node.DEFMETHOD("reset_opt_flags", function(compressor, rescan){
var reduce_vars = rescan && compressor.option("reduce_vars");
+ var toplevel = compressor.option("toplevel");
var ie8 = !compressor.option("screw_ie8");
var safe_ids = [];
push();
@@ -334,7 +335,11 @@ merge(Compressor.prototype, {
}
function reset_def(def) {
- def.fixed = undefined;
+ if (toplevel || !def.global || def.orig[0] instanceof AST_SymbolConst) {
+ def.fixed = undefined;
+ } else {
+ def.fixed = false;
+ }
def.references = [];
def.should_replace = undefined;
}