fix toplevel on export (#2137)

fixes #2134
This commit is contained in:
Alex Lam S.L
2017-06-22 00:31:17 +08:00
committed by GitHub
parent 71556d00b5
commit 8ba9e4e0da
2 changed files with 38 additions and 1 deletions

View File

@@ -129,7 +129,9 @@ function Compressor(options, false_by_default) {
this.toplevel.funcs = /funcs/.test(toplevel);
this.toplevel.vars = /vars/.test(toplevel);
} else {
this.toplevel = toplevel ? return_true : return_false;
this.toplevel = toplevel ? function(def) {
return !def.export;
} : return_false;
this.toplevel.funcs = this.toplevel.vars = toplevel;
}
var sequences = this.options["sequences"];
@@ -141,6 +143,7 @@ Compressor.prototype = new TreeTransformer;
merge(Compressor.prototype, {
option: function(key) { return this.options[key] },
toplevel: function(def) {
if (def.export) return false;
for (var i = 0, len = def.orig.length; i < len; i++)
if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
return false;