avoid substitution of global variables (#1557)

- unless `toplevel` is enabled
- global `const` works as before
This commit is contained in:
Alex Lam S.L
2017-03-07 03:11:03 +08:00
committed by GitHub
parent 3ac2421932
commit d787d70127
3 changed files with 306 additions and 93 deletions

View File

@@ -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;
}