@@ -10234,22 +10234,24 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
|
||||
function varify(self, compressor) {
|
||||
return all(self.definitions, function(defn) {
|
||||
if (all(self.definitions, function(defn) {
|
||||
return !defn.name.match_symbol(function(node) {
|
||||
if (node instanceof AST_SymbolDeclaration) return !can_varify(compressor, node);
|
||||
}, true);
|
||||
}) ? to_var(self, compressor.find_parent(AST_Scope)) : self;
|
||||
})) return to_var(self, compressor.find_parent(AST_Scope));
|
||||
}
|
||||
|
||||
OPT(AST_Const, function(self, compressor) {
|
||||
if (!compressor.option("varify")) return self;
|
||||
var decl = varify(self, compressor);
|
||||
if (decl) return decl;
|
||||
if (can_letify(self, compressor, 0)) return to_let(self);
|
||||
return varify(self, compressor);
|
||||
return self;
|
||||
});
|
||||
|
||||
OPT(AST_Let, function(self, compressor) {
|
||||
if (!compressor.option("varify")) return self;
|
||||
return varify(self, compressor);
|
||||
return varify(self, compressor) || self;
|
||||
});
|
||||
|
||||
function trim_optional_chain(node, compressor) {
|
||||
|
||||
@@ -82,14 +82,14 @@ function minify(files, options) {
|
||||
keep_fargs: false,
|
||||
keep_fnames: false,
|
||||
mangle: {},
|
||||
module: false,
|
||||
module: undefined,
|
||||
nameCache: null,
|
||||
output: {},
|
||||
parse: {},
|
||||
rename: undefined,
|
||||
sourceMap: false,
|
||||
timings: false,
|
||||
toplevel: !!(options && !options["expression"] && options["module"]),
|
||||
toplevel: undefined,
|
||||
v8: false,
|
||||
validate: false,
|
||||
warnings: false,
|
||||
@@ -104,8 +104,10 @@ function minify(files, options) {
|
||||
if (options.ie) set_shorthand("ie", options, [ "compress", "mangle", "output", "rename" ]);
|
||||
if (options.keep_fargs) set_shorthand("keep_fargs", options, [ "compress", "mangle", "rename" ]);
|
||||
if (options.keep_fnames) set_shorthand("keep_fnames", options, [ "compress", "mangle", "rename" ]);
|
||||
if (options.module === undefined && !options.ie) options.module = true;
|
||||
if (options.module) set_shorthand("module", options, [ "compress", "parse" ]);
|
||||
if (options.toplevel) set_shorthand("toplevel", options, [ "compress", "mangle", "rename" ]);
|
||||
if (options.toplevel === undefined && !options.expression && options.module) options.toplevel = true;
|
||||
if (options.toplevel !== undefined) set_shorthand("toplevel", options, [ "compress", "mangle", "rename" ]);
|
||||
if (options.v8) set_shorthand("v8", options, [ "mangle", "output", "rename" ]);
|
||||
if (options.webkit) set_shorthand("webkit", options, [ "compress", "mangle", "output", "rename" ]);
|
||||
var quoted_props;
|
||||
|
||||
12
lib/scope.js
12
lib/scope.js
@@ -68,9 +68,7 @@ SymbolDef.prototype = {
|
||||
var cache = this.global && options.cache && options.cache.props;
|
||||
if (cache && cache.has(this.name)) {
|
||||
this.mangled_name = cache.get(this.name);
|
||||
} else if (this.unmangleable(options)) {
|
||||
names_in_use(this.scope, options).set(this.name, true);
|
||||
} else {
|
||||
} else if (!this.unmangleable(options)) {
|
||||
var def = this.redefined();
|
||||
if (def) {
|
||||
this.mangled_name = def.mangled_name || def.name;
|
||||
@@ -651,8 +649,12 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
||||
}, true);
|
||||
}
|
||||
var to_mangle = node.to_mangle = [];
|
||||
node.variables.each(function(def) {
|
||||
if (!defer_redef(def)) to_mangle.push(def);
|
||||
node.variables.each(function(def, name) {
|
||||
if (def.unmangleable(options)) {
|
||||
names_in_use(node, options).set(name, true);
|
||||
} else if (!defer_redef(def)) {
|
||||
to_mangle.push(def);
|
||||
}
|
||||
});
|
||||
descend();
|
||||
if (options.cache && node instanceof AST_Toplevel) {
|
||||
|
||||
Reference in New Issue
Block a user