Update dependencies
This commit is contained in:
parent
686c644751
commit
6b024302d3
7679 changed files with 179547 additions and 183379 deletions
21
node_modules/uglify-js/lib/ast.js
generated
vendored
21
node_modules/uglify-js/lib/ast.js
generated
vendored
|
@ -827,6 +827,9 @@ var AST_Class = DEFNODE("Class", "extends name properties", {
|
|||
extends: "[AST_Node?] the super class, or null if not specified",
|
||||
properties: "[AST_ClassProperty*] array of class properties",
|
||||
},
|
||||
resolve: function(def_class) {
|
||||
return def_class ? this : this.parent_scope.resolve();
|
||||
},
|
||||
walk: function(visitor) {
|
||||
var node = this;
|
||||
visitor.visit(node, function() {
|
||||
|
@ -851,9 +854,6 @@ var AST_DefClass = DEFNODE("DefClass", null, {
|
|||
$propdoc: {
|
||||
name: "[AST_SymbolDefClass] the name of this class",
|
||||
},
|
||||
resolve: function(def_class) {
|
||||
return def_class ? this : this.parent_scope.resolve();
|
||||
},
|
||||
_validate: function() {
|
||||
if (!(this.name instanceof AST_SymbolDefClass)) throw new Error("name must be AST_SymbolDefClass");
|
||||
},
|
||||
|
@ -1837,7 +1837,7 @@ var AST_Label = DEFNODE("Label", "references", {
|
|||
initialize: function() {
|
||||
this.references = [];
|
||||
this.thedef = this;
|
||||
}
|
||||
},
|
||||
}, AST_Symbol);
|
||||
|
||||
var AST_SymbolRef = DEFNODE("SymbolRef", "fixed in_arg redef", {
|
||||
|
@ -2039,16 +2039,21 @@ TreeWalker.prototype = {
|
|||
return this.stack[this.stack.length - 2 - (n || 0)];
|
||||
},
|
||||
push: function(node) {
|
||||
if (node instanceof AST_Lambda) {
|
||||
var value;
|
||||
if (node instanceof AST_Class) {
|
||||
this.directives = Object.create(this.directives);
|
||||
value = "use strict";
|
||||
} else if (node instanceof AST_Directive) {
|
||||
value = node.value;
|
||||
} else if (node instanceof AST_Lambda) {
|
||||
this.directives = Object.create(this.directives);
|
||||
} else if (node instanceof AST_Directive && !this.directives[node.value]) {
|
||||
this.directives[node.value] = node;
|
||||
}
|
||||
if (value && !this.directives[value]) this.directives[value] = node;
|
||||
this.stack.push(node);
|
||||
},
|
||||
pop: function() {
|
||||
var node = this.stack.pop();
|
||||
if (node instanceof AST_Lambda) {
|
||||
if (node instanceof AST_Class || node instanceof AST_Lambda) {
|
||||
this.directives = Object.getPrototypeOf(this.directives);
|
||||
}
|
||||
},
|
||||
|
|
328
node_modules/uglify-js/lib/compress.js
generated
vendored
328
node_modules/uglify-js/lib/compress.js
generated
vendored
|
@ -80,6 +80,7 @@ function Compressor(options, false_by_default) {
|
|||
keep_infinity : false,
|
||||
loops : !false_by_default,
|
||||
merge_vars : !false_by_default,
|
||||
module : false,
|
||||
negate_iife : !false_by_default,
|
||||
objects : !false_by_default,
|
||||
optional_chains : !false_by_default,
|
||||
|
@ -97,7 +98,7 @@ function Compressor(options, false_by_default) {
|
|||
switches : !false_by_default,
|
||||
templates : !false_by_default,
|
||||
top_retain : null,
|
||||
toplevel : !!(options && options["top_retain"]),
|
||||
toplevel : !!(options && (options["module"] || options["top_retain"])),
|
||||
typeofs : !false_by_default,
|
||||
unsafe : false,
|
||||
unsafe_comps : false,
|
||||
|
@ -130,6 +131,7 @@ function Compressor(options, false_by_default) {
|
|||
var escaped = def.escaped;
|
||||
return escaped && escaped.depth != 1;
|
||||
};
|
||||
if (this.options["module"]) this.directives["use strict"] = true;
|
||||
var pure_funcs = this.options["pure_funcs"];
|
||||
if (typeof pure_funcs == "function") {
|
||||
this.pure_funcs = pure_funcs;
|
||||
|
@ -766,14 +768,14 @@ Compressor.prototype.compress = function(node) {
|
|||
function make_fixed_default(compressor, node, save) {
|
||||
var prev_save, prev_seq;
|
||||
return function() {
|
||||
if (prev_seq === node) return node;
|
||||
var current = save();
|
||||
var ev;
|
||||
if (!is_undefined(current, compressor) && (ev = fuzzy_eval(compressor, current, true)) !== undefined) {
|
||||
return ev instanceof AST_Node ? node : current;
|
||||
}
|
||||
if (prev_save !== current) {
|
||||
var ev = fuzzy_eval(compressor, current, true);
|
||||
if (ev instanceof AST_Node) {
|
||||
prev_seq = node;
|
||||
} else if (prev_save !== current) {
|
||||
prev_save = current;
|
||||
prev_seq = make_sequence(node, [ current, node.value ]);
|
||||
prev_seq = ev === undefined ? make_sequence(node, [ current, node.value ]) : current;
|
||||
}
|
||||
return prev_seq;
|
||||
};
|
||||
|
@ -1557,7 +1559,10 @@ Compressor.prototype.compress = function(node) {
|
|||
|
||||
AST_SymbolRef.DEFMETHOD("is_immutable", function() {
|
||||
var def = this.redef || this.definition();
|
||||
return (this.in_arg || def.orig.length == 1) && def.orig[0] instanceof AST_SymbolLambda;
|
||||
if (!(def.orig[0] instanceof AST_SymbolLambda)) return false;
|
||||
if (def.orig.length == 1) return true;
|
||||
if (!this.in_arg) return false;
|
||||
return !(def.orig[1] instanceof AST_SymbolFunarg);
|
||||
});
|
||||
|
||||
AST_Node.DEFMETHOD("convert_symbol", noop);
|
||||
|
@ -2464,6 +2469,13 @@ Compressor.prototype.compress = function(node) {
|
|||
abort = false;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Class) {
|
||||
if (!in_try) return false;
|
||||
var base = node.extends;
|
||||
if (!base) return false;
|
||||
if (base instanceof AST_SymbolRef) base = base.fixed_value();
|
||||
return !safe_for_extends(base);
|
||||
}
|
||||
if (node instanceof AST_Exit) {
|
||||
if (in_try) {
|
||||
if (in_try.bfinally) return true;
|
||||
|
@ -2552,8 +2564,8 @@ Compressor.prototype.compress = function(node) {
|
|||
&& all(iife.args, function(arg) {
|
||||
return !(arg instanceof AST_Spread);
|
||||
})) {
|
||||
var fn_strict = compressor.has_directive("use strict");
|
||||
if (fn_strict && !member(fn_strict, fn.body)) fn_strict = false;
|
||||
var fn_strict = fn.in_strict_mode(compressor)
|
||||
&& !fn.parent_scope.resolve(true).in_strict_mode(compressor);
|
||||
var has_await = is_async(fn) ? function(node) {
|
||||
return node instanceof AST_Symbol && node.name == "await";
|
||||
} : function(node) {
|
||||
|
@ -4120,6 +4132,25 @@ Compressor.prototype.compress = function(node) {
|
|||
&& !(compressor && node.expression.has_side_effects(compressor));
|
||||
}
|
||||
|
||||
// in_strict_mode()
|
||||
// return true if scope executes in Strict Mode
|
||||
(function(def) {
|
||||
def(AST_Class, return_true);
|
||||
def(AST_Scope, function(compressor) {
|
||||
var body = this.body;
|
||||
for (var i = 0; i < body.length; i++) {
|
||||
var stat = body[i];
|
||||
if (!(stat instanceof AST_Directive)) break;
|
||||
if (stat.value == "use strict") return true;
|
||||
}
|
||||
var parent = this.parent_scope;
|
||||
if (!parent) return compressor.option("module");
|
||||
return parent.resolve(true).in_strict_mode(compressor);
|
||||
});
|
||||
})(function(node, func) {
|
||||
node.DEFMETHOD("in_strict_mode", func);
|
||||
});
|
||||
|
||||
// is_truthy()
|
||||
// return true if `!!node === true`
|
||||
(function(def) {
|
||||
|
@ -6015,7 +6046,7 @@ Compressor.prototype.compress = function(node) {
|
|||
var NO_MERGE = makePredicate("arguments await yield");
|
||||
AST_Scope.DEFMETHOD("merge_variables", function(compressor) {
|
||||
if (!compressor.option("merge_vars")) return;
|
||||
var in_try, root, segment = {}, self = this;
|
||||
var in_arg = [], in_try, root, segment = {}, self = this;
|
||||
var first = [], last = [], index = 0;
|
||||
var declarations = new Dictionary();
|
||||
var references = Object.create(null);
|
||||
|
@ -6026,31 +6057,7 @@ Compressor.prototype.compress = function(node) {
|
|||
var rhs = node.right;
|
||||
if (lhs instanceof AST_Destructured) {
|
||||
rhs.walk(tw);
|
||||
var marker = new TreeWalker(function(node) {
|
||||
if (node instanceof AST_Destructured) return;
|
||||
if (node instanceof AST_DefaultValue) {
|
||||
push();
|
||||
node.value.walk(tw);
|
||||
pop();
|
||||
node.name.walk(marker);
|
||||
} else if (node instanceof AST_DestructuredKeyVal) {
|
||||
if (node.key instanceof AST_Node) {
|
||||
push();
|
||||
segment.block = node;
|
||||
node.key.walk(tw);
|
||||
node.value.walk(marker);
|
||||
pop();
|
||||
} else {
|
||||
node.value.walk(marker);
|
||||
}
|
||||
} else if (node instanceof AST_SymbolRef) {
|
||||
mark(node);
|
||||
} else {
|
||||
node.walk(tw);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
lhs.walk(marker);
|
||||
walk_destructured(AST_SymbolRef, mark, lhs);
|
||||
return true;
|
||||
}
|
||||
if (lazy_op[node.operator.slice(0, -1)]) {
|
||||
|
@ -6170,37 +6177,17 @@ Compressor.prototype.compress = function(node) {
|
|||
if (node === self) root = segment;
|
||||
if (node instanceof AST_Lambda) {
|
||||
if (node.name) references[node.name.definition().id] = false;
|
||||
var parent = tw.parent();
|
||||
var in_iife = parent && parent.TYPE == "Call" && parent.expression === node;
|
||||
var marker = node.uses_arguments && !tw.has_directive("use strict") ? function(node) {
|
||||
if (node instanceof AST_SymbolFunarg) references[node.definition().id] = false;
|
||||
references[node.definition().id] = false;
|
||||
} : function(node) {
|
||||
if (node instanceof AST_SymbolFunarg) mark(node);
|
||||
mark(node);
|
||||
};
|
||||
var scanner = new TreeWalker(function(ref) {
|
||||
if (ref instanceof AST_SymbolDeclaration) references[ref.definition().id] = false;
|
||||
if (!(ref instanceof AST_SymbolRef)) return;
|
||||
var def = ref.definition();
|
||||
var ldef = node.variables.get(ref.name);
|
||||
if (ldef && (ldef === def
|
||||
|| def.undeclared
|
||||
|| node.parent_scope.find_variable(ref.name) === def)) {
|
||||
references[def.id] = false;
|
||||
references[ldef.id] = false;
|
||||
} else if (in_iife) {
|
||||
var save = segment;
|
||||
pop();
|
||||
mark(ref, true);
|
||||
segment = save;
|
||||
} else {
|
||||
mark(ref, true);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
in_arg.push(node);
|
||||
node.argnames.forEach(function(argname) {
|
||||
argname.mark_symbol(marker, scanner);
|
||||
walk_destructured(AST_SymbolFunarg, marker, argname);
|
||||
});
|
||||
if (node.rest) node.rest.mark_symbol(marker, scanner);
|
||||
if (node.rest) walk_destructured(AST_SymbolFunarg, marker, node.rest);
|
||||
in_arg.pop();
|
||||
}
|
||||
walk_lambda(node, tw);
|
||||
pop();
|
||||
|
@ -6414,8 +6401,45 @@ Compressor.prototype.compress = function(node) {
|
|||
segment = Object.getPrototypeOf(segment);
|
||||
}
|
||||
|
||||
function walk_destructured(symbol_type, mark, lhs) {
|
||||
var marker = new TreeWalker(function(node) {
|
||||
if (node instanceof AST_Destructured) return;
|
||||
if (node instanceof AST_DefaultValue) {
|
||||
push();
|
||||
node.value.walk(tw);
|
||||
pop();
|
||||
node.name.walk(marker);
|
||||
} else if (node instanceof AST_DestructuredKeyVal) {
|
||||
if (node.key instanceof AST_Node) {
|
||||
push();
|
||||
segment.block = node;
|
||||
node.key.walk(tw);
|
||||
node.value.walk(marker);
|
||||
pop();
|
||||
} else {
|
||||
node.value.walk(marker);
|
||||
}
|
||||
} else if (node instanceof symbol_type) {
|
||||
mark(node);
|
||||
} else {
|
||||
node.walk(tw);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
lhs.walk(marker);
|
||||
}
|
||||
|
||||
function mark(sym, read) {
|
||||
var def = sym.definition(), ldef, seg = segment;
|
||||
var def = sym.definition(), ldef;
|
||||
if (read && !all(in_arg, function(fn) {
|
||||
ldef = fn.variables.get(sym.name);
|
||||
if (!ldef) return true;
|
||||
if (!is_funarg(ldef)) return true;
|
||||
return ldef !== def
|
||||
&& !def.undeclared
|
||||
&& fn.parent_scope.find_variable(sym.name) !== def;
|
||||
})) return references[def.id] = references[ldef.id] = false;
|
||||
var seg = segment;
|
||||
if (in_try) {
|
||||
push();
|
||||
seg = segment;
|
||||
|
@ -6774,7 +6798,6 @@ Compressor.prototype.compress = function(node) {
|
|||
}
|
||||
});
|
||||
// pass 3: we should drop declarations not in_use
|
||||
var unused_fn_names = [];
|
||||
var calls_to_drop_args = [];
|
||||
var fns_with_marked_args = [];
|
||||
var trimmer = new TreeTransformer(function(node) {
|
||||
|
@ -6895,7 +6918,7 @@ Compressor.prototype.compress = function(node) {
|
|||
}
|
||||
}
|
||||
if (node instanceof AST_ClassExpression && node.name && drop_fn_name(node.name.definition())) {
|
||||
unused_fn_names.push(node);
|
||||
node.name = null;
|
||||
}
|
||||
if (node instanceof AST_Lambda) {
|
||||
if (drop_funcs && node !== self && node instanceof AST_LambdaDefinition) {
|
||||
|
@ -6911,7 +6934,7 @@ Compressor.prototype.compress = function(node) {
|
|||
}
|
||||
}
|
||||
if (node instanceof AST_LambdaExpression && node.name && drop_fn_name(node.name.definition())) {
|
||||
unused_fn_names.push(node);
|
||||
node.name = null;
|
||||
}
|
||||
if (!(node instanceof AST_Accessor)) {
|
||||
var args, spread, trim = compressor.drop_fargs(node, parent);
|
||||
|
@ -6923,7 +6946,9 @@ Compressor.prototype.compress = function(node) {
|
|||
}
|
||||
var argnames = node.argnames;
|
||||
var rest = node.rest;
|
||||
var after = false, before = false;
|
||||
if (rest) {
|
||||
before = true;
|
||||
if (!args || spread < argnames.length || rest instanceof AST_SymbolFunarg) {
|
||||
rest = rest.transform(trimmer);
|
||||
} else {
|
||||
|
@ -6936,8 +6961,7 @@ Compressor.prototype.compress = function(node) {
|
|||
args.length = argnames.length;
|
||||
if (trimmed.value.elements.length) [].push.apply(args, trimmed.value.elements);
|
||||
}
|
||||
if (rest instanceof AST_Destructured && !rest.rest
|
||||
&& (!node.uses_arguments || tt.has_directive("use strict"))) {
|
||||
if (rest instanceof AST_Destructured && !rest.rest) {
|
||||
if (rest instanceof AST_DestructuredArray) {
|
||||
if (rest.elements.length == 0) rest = null;
|
||||
} else if (rest.properties.length == 0) {
|
||||
|
@ -6945,9 +6969,13 @@ Compressor.prototype.compress = function(node) {
|
|||
}
|
||||
}
|
||||
node.rest = rest;
|
||||
if (rest) trim = false;
|
||||
if (rest) {
|
||||
trim = false;
|
||||
after = true;
|
||||
}
|
||||
}
|
||||
var default_length = trim ? -1 : node.length();
|
||||
var trim_value = args && !node.uses_arguments && parent !== compressor.parent();
|
||||
for (var i = argnames.length; --i >= 0;) {
|
||||
var sym = argnames[i];
|
||||
if (sym instanceof AST_SymbolFunarg) {
|
||||
|
@ -6962,29 +6990,43 @@ Compressor.prototype.compress = function(node) {
|
|||
sym.unused = true;
|
||||
}
|
||||
} else {
|
||||
before = true;
|
||||
var funarg;
|
||||
if (!args || spread < i) {
|
||||
funarg = sym.transform(trimmer);
|
||||
} else {
|
||||
funarg = trim_destructured(sym, args[i], function(node) {
|
||||
var trimmed = trim_destructured(sym, args[i], function(node) {
|
||||
return node.definition().id in in_use_ids ? node : null;
|
||||
}, !node.uses_arguments, sym).name;
|
||||
}, trim_value, sym);
|
||||
funarg = trimmed.name;
|
||||
if (trimmed.value) args[i] = trimmed.value;
|
||||
}
|
||||
if (funarg) {
|
||||
trim = false;
|
||||
argnames[i] = funarg;
|
||||
if (!after) after = !(funarg instanceof AST_SymbolFunarg);
|
||||
} else if (trim) {
|
||||
log_default(sym, "Dropping unused default argument {name}");
|
||||
argnames.pop();
|
||||
} else if (i > default_length) {
|
||||
log_default(sym, "Dropping unused default argument assignment {name}");
|
||||
if (sym.name instanceof AST_SymbolFunarg) sym.name.unused = true;
|
||||
if (sym.name instanceof AST_SymbolFunarg) {
|
||||
sym.name.unused = true;
|
||||
} else {
|
||||
after = true;
|
||||
}
|
||||
argnames[i] = sym.name;
|
||||
} else {
|
||||
log_default(sym, "Dropping unused default argument value {name}");
|
||||
argnames[i] = sym = sym.clone();
|
||||
sym.value = make_node(AST_Number, sym, { value: 0 });
|
||||
after = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (before && !after && node.uses_arguments && !tt.has_directive("use strict")) {
|
||||
node.rest = make_node(AST_DestructuredArray, node, { elements: [] });
|
||||
}
|
||||
fns_with_marked_args.push(node);
|
||||
}
|
||||
}
|
||||
|
@ -7208,6 +7250,7 @@ Compressor.prototype.compress = function(node) {
|
|||
});
|
||||
var index = indexOf_assign(sym, def);
|
||||
if (index >= 0) assign_in_use[sym.id][index] = assign;
|
||||
sym.assignments++;
|
||||
sym.eliminated++;
|
||||
return assign;
|
||||
}));
|
||||
|
@ -7283,6 +7326,13 @@ Compressor.prototype.compress = function(node) {
|
|||
}
|
||||
}, function(node, in_list) {
|
||||
if (node instanceof AST_BlockStatement) return trim_block(node, tt.parent(), in_list);
|
||||
if (node instanceof AST_ExportDeclaration) {
|
||||
var block = node.body;
|
||||
if (!(block instanceof AST_BlockStatement)) return;
|
||||
node.body = block.body.pop();
|
||||
block.body.push(node);
|
||||
return in_list ? List.splice(block.body) : block;
|
||||
}
|
||||
if (node instanceof AST_For) return patch_for_init(node, in_list);
|
||||
if (node instanceof AST_ForIn) {
|
||||
if (!drop_vars || !compressor.option("loops")) return;
|
||||
|
@ -7316,6 +7366,7 @@ Compressor.prototype.compress = function(node) {
|
|||
}
|
||||
});
|
||||
tt.push(compressor.parent());
|
||||
tt.directives = Object.create(compressor.directives);
|
||||
self.transform(tt);
|
||||
if (self instanceof AST_Lambda
|
||||
&& self.body.length == 1
|
||||
|
@ -7323,9 +7374,6 @@ Compressor.prototype.compress = function(node) {
|
|||
&& self.body[0].value == "use strict") {
|
||||
self.body.length = 0;
|
||||
}
|
||||
unused_fn_names.forEach(function(fn) {
|
||||
fn.name = null;
|
||||
});
|
||||
calls_to_drop_args.forEach(function(call) {
|
||||
drop_unused_call_args(call, compressor, fns_with_marked_args);
|
||||
});
|
||||
|
@ -7537,6 +7585,7 @@ Compressor.prototype.compress = function(node) {
|
|||
var value = node.value.drop_side_effect_free(compressor);
|
||||
if (!value) return null;
|
||||
log(node.name, "Side effects in default value of unused variable {name}");
|
||||
node = node.clone();
|
||||
node.name.unused = null;
|
||||
node.value = value;
|
||||
}
|
||||
|
@ -7614,6 +7663,7 @@ Compressor.prototype.compress = function(node) {
|
|||
drop = save_drop;
|
||||
if (values && newValues) {
|
||||
fill_holes(value, newValues);
|
||||
value = value.clone();
|
||||
value.elements = newValues;
|
||||
}
|
||||
if (!node.rest && (value instanceof AST_Array
|
||||
|
@ -7647,20 +7697,25 @@ Compressor.prototype.compress = function(node) {
|
|||
drop = false;
|
||||
value = value.fixed_value();
|
||||
}
|
||||
var prop_keys, prop_map;
|
||||
var prop_keys, prop_map, values;
|
||||
if (value instanceof AST_Object) {
|
||||
prop_keys = [];
|
||||
prop_map = new Dictionary();
|
||||
value.properties.forEach(function(prop, index) {
|
||||
if (prop instanceof AST_Spread) return prop_map = false;
|
||||
var key = prop.key;
|
||||
if (key instanceof AST_Node) key = key.evaluate(compressor, true);
|
||||
if (key instanceof AST_Node) {
|
||||
values = value.properties.map(function(prop, index) {
|
||||
prop = prop.clone();
|
||||
if (prop instanceof AST_Spread) {
|
||||
prop_map = false;
|
||||
} else if (prop_map && !(prop instanceof AST_ObjectSetter)) {
|
||||
prop_map.set(key, prop);
|
||||
} else {
|
||||
var key = prop.key;
|
||||
if (key instanceof AST_Node) key = key.evaluate(compressor, true);
|
||||
if (key instanceof AST_Node) {
|
||||
prop_map = false;
|
||||
} else if (prop_map && !(prop instanceof AST_ObjectSetter)) {
|
||||
prop_map.set(key, prop);
|
||||
}
|
||||
prop_keys[index] = key;
|
||||
}
|
||||
prop_keys[index] = key;
|
||||
return prop;
|
||||
});
|
||||
}
|
||||
if (node.rest) {
|
||||
|
@ -7725,27 +7780,30 @@ Compressor.prototype.compress = function(node) {
|
|||
});
|
||||
value = save_value;
|
||||
drop = save_drop;
|
||||
if (drop_keys && prop_keys) value.properties = List(value.properties, function(prop, index) {
|
||||
if (prop instanceof AST_Spread) return prop;
|
||||
var key = prop_keys[index];
|
||||
if (key instanceof AST_Node) return prop;
|
||||
if (drop_keys.has(key)) {
|
||||
var mapped = drop_keys.get(key);
|
||||
if (!mapped) return prop;
|
||||
if (mapped === prop) return prop_map.get(key) || List.skip;
|
||||
} else if (node.rest) {
|
||||
return prop;
|
||||
}
|
||||
var trimmed = prop.value.drop_side_effect_free(compressor);
|
||||
if (trimmed) {
|
||||
prop.value = trimmed;
|
||||
return prop;
|
||||
}
|
||||
return retain_key(prop) ? make_node(AST_ObjectKeyVal, prop, {
|
||||
key: prop.key,
|
||||
value: make_node(AST_Number, prop, { value: 0 }),
|
||||
}) : List.skip;
|
||||
});
|
||||
if (drop_keys && prop_keys) {
|
||||
value = value.clone();
|
||||
value.properties = List(values, function(prop, index) {
|
||||
if (prop instanceof AST_Spread) return prop;
|
||||
var key = prop_keys[index];
|
||||
if (key instanceof AST_Node) return prop;
|
||||
if (drop_keys.has(key)) {
|
||||
var mapped = drop_keys.get(key);
|
||||
if (!mapped) return prop;
|
||||
if (mapped === prop) return prop_map.get(key) || List.skip;
|
||||
} else if (node.rest) {
|
||||
return prop;
|
||||
}
|
||||
var trimmed = prop.value.drop_side_effect_free(compressor);
|
||||
if (trimmed) {
|
||||
prop.value = trimmed;
|
||||
return prop;
|
||||
}
|
||||
return retain_key(prop) ? make_node(AST_ObjectKeyVal, prop, {
|
||||
key: prop.key,
|
||||
value: make_node(AST_Number, prop, { value: 0 }),
|
||||
}) : List.skip;
|
||||
});
|
||||
}
|
||||
if (value && !node.rest) switch (properties.length) {
|
||||
case 0:
|
||||
if (node === root) break;
|
||||
|
@ -8138,12 +8196,12 @@ Compressor.prototype.compress = function(node) {
|
|||
var self = this;
|
||||
var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
|
||||
var defs_by_id = Object.create(null);
|
||||
self.transform(new TreeTransformer(function(node, descend) {
|
||||
var tt = new TreeTransformer(function(node, descend) {
|
||||
if (node instanceof AST_Assign) {
|
||||
if (node.operator != "=") return;
|
||||
if (!node.write_only) return;
|
||||
if (!can_hoist(node.left, node.right, 1)) return;
|
||||
descend(node, this);
|
||||
descend(node, tt);
|
||||
var defs = new Dictionary();
|
||||
var assignments = [];
|
||||
var decls = [];
|
||||
|
@ -8167,15 +8225,20 @@ Compressor.prototype.compress = function(node) {
|
|||
});
|
||||
defs.value = node.right;
|
||||
defs_by_id[node.left.definition().id] = defs;
|
||||
self.body.splice(self.body.indexOf(this.stack[1]) + 1, 0, make_node(AST_Var, node, {
|
||||
self.body.splice(self.body.indexOf(tt.stack[1]) + 1, 0, make_node(AST_Var, node, {
|
||||
definitions: decls,
|
||||
}));
|
||||
return make_sequence(node, assignments);
|
||||
}
|
||||
if (node instanceof AST_Scope) return node === self ? undefined : node;
|
||||
if (node instanceof AST_Scope) {
|
||||
if (node === self) return;
|
||||
var parent = tt.parent();
|
||||
if (parent.TYPE == "Call" && parent.expression === node) return;
|
||||
return node;
|
||||
}
|
||||
if (node instanceof AST_VarDef) {
|
||||
if (!can_hoist(node.name, node.value, 0)) return;
|
||||
descend(node, this);
|
||||
descend(node, tt);
|
||||
var defs = new Dictionary();
|
||||
var var_defs = [];
|
||||
var decl = node.clone();
|
||||
|
@ -8197,7 +8260,8 @@ Compressor.prototype.compress = function(node) {
|
|||
defs.set(key, new_var.definition());
|
||||
return new_var;
|
||||
}
|
||||
}));
|
||||
});
|
||||
self.transform(tt);
|
||||
self.transform(new TreeTransformer(function(node, descend) {
|
||||
if (node instanceof AST_PropAccess) {
|
||||
if (!(node.expression instanceof AST_SymbolRef)) return;
|
||||
|
@ -8227,6 +8291,7 @@ Compressor.prototype.compress = function(node) {
|
|||
if (def.assignments != count) return;
|
||||
if (def.references.length - def.replaced == count) return;
|
||||
if (def.single_use) return;
|
||||
if (self.find_variable(sym.name) !== def) return;
|
||||
if (top_retain(def)) return;
|
||||
if (sym.fixed_value() !== right) return;
|
||||
var fixed = sym.fixed || def.fixed;
|
||||
|
@ -8290,6 +8355,9 @@ Compressor.prototype.compress = function(node) {
|
|||
var dropped = value.drop_side_effect_free(compressor);
|
||||
if (dropped !== value) {
|
||||
changed = true;
|
||||
if (dropped && async && !is_primitive(compressor, dropped)) {
|
||||
dropped = dropped.negate(compressor);
|
||||
}
|
||||
node.value = dropped;
|
||||
}
|
||||
}
|
||||
|
@ -9098,6 +9166,7 @@ Compressor.prototype.compress = function(node) {
|
|||
|
||||
function fuzzy_eval(compressor, node, nullish) {
|
||||
if (node.truthy) return true;
|
||||
if (is_undefined(node)) return undefined;
|
||||
if (node.falsy && !nullish) return false;
|
||||
if (node.is_truthy()) return true;
|
||||
return node.evaluate(compressor, true);
|
||||
|
@ -9112,17 +9181,20 @@ Compressor.prototype.compress = function(node) {
|
|||
child = parent;
|
||||
parent = compressor.parent(level++);
|
||||
if (parent instanceof AST_Binary) {
|
||||
var op = parent.operator;
|
||||
if (!lazy_op[op]) return;
|
||||
var left = parent.left;
|
||||
if (left === child) continue;
|
||||
if (match(left)) switch (op) {
|
||||
case "&&":
|
||||
node[negated ? "falsy" : "truthy"] = true;
|
||||
switch (child) {
|
||||
case parent.left:
|
||||
if (lazy_op[parent.operator]) continue;
|
||||
break;
|
||||
case "||":
|
||||
case "??":
|
||||
node[negated ? "truthy" : "falsy"] = true;
|
||||
case parent.right:
|
||||
if (match(parent.left)) switch (parent.operator) {
|
||||
case "&&":
|
||||
node[negated ? "falsy" : "truthy"] = true;
|
||||
break;
|
||||
case "||":
|
||||
case "??":
|
||||
node[negated ? "truthy" : "falsy"] = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (parent instanceof AST_Conditional) {
|
||||
|
@ -9882,6 +9954,10 @@ Compressor.prototype.compress = function(node) {
|
|||
return safe;
|
||||
}
|
||||
|
||||
function safe_from_strict_mode(fn, compressor) {
|
||||
return fn.in_strict_mode(compressor) || !compressor.has_directive("use strict");
|
||||
}
|
||||
|
||||
OPT(AST_Call, function(self, compressor) {
|
||||
var exp = self.expression;
|
||||
var terminated = trim_optional_chain(self, compressor);
|
||||
|
@ -10206,7 +10282,10 @@ Compressor.prototype.compress = function(node) {
|
|||
}
|
||||
return true;
|
||||
}) && !(fn.rest instanceof AST_Destructured && has_arg_refs(fn, fn.rest));
|
||||
var can_inline = can_drop && compressor.option("inline") && !self.is_expr_pure(compressor);
|
||||
var can_inline = can_drop
|
||||
&& compressor.option("inline")
|
||||
&& !self.is_expr_pure(compressor)
|
||||
&& (exp === fn || safe_from_strict_mode(fn, compressor));
|
||||
if (can_inline && stat instanceof AST_Return) {
|
||||
var value = stat.value;
|
||||
if (exp === fn
|
||||
|
@ -11813,8 +11892,9 @@ Compressor.prototype.compress = function(node) {
|
|||
} else if (fixed.name && fixed.name.definition() !== def) {
|
||||
single_use = false;
|
||||
} else if (fixed.parent_scope !== self.scope || is_funarg(def)) {
|
||||
single_use = fixed.is_constant_expression(self.scope);
|
||||
if (single_use == "f") {
|
||||
if (!safe_from_strict_mode(fixed, compressor)) {
|
||||
single_use = false;
|
||||
} else if ((single_use = fixed.is_constant_expression(self.scope)) == "f") {
|
||||
var scope = self.scope;
|
||||
do {
|
||||
if (scope instanceof AST_LambdaDefinition || scope instanceof AST_LambdaExpression) {
|
||||
|
|
4
node_modules/uglify-js/lib/minify.js
generated
vendored
4
node_modules/uglify-js/lib/minify.js
generated
vendored
|
@ -81,13 +81,14 @@ function minify(files, options) {
|
|||
keep_fargs: false,
|
||||
keep_fnames: false,
|
||||
mangle: {},
|
||||
module: false,
|
||||
nameCache: null,
|
||||
output: {},
|
||||
parse: {},
|
||||
rename: undefined,
|
||||
sourceMap: false,
|
||||
timings: false,
|
||||
toplevel: false,
|
||||
toplevel: !!(options && options["module"]),
|
||||
v8: false,
|
||||
validate: false,
|
||||
warnings: false,
|
||||
|
@ -101,6 +102,7 @@ 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) set_shorthand("module", options, [ "compress", "parse" ]);
|
||||
if (options.toplevel) 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" ]);
|
||||
|
|
26
node_modules/uglify-js/lib/parse.js
generated
vendored
26
node_modules/uglify-js/lib/parse.js
generated
vendored
|
@ -237,8 +237,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|||
newline_before : false,
|
||||
regex_allowed : false,
|
||||
comments_before : [],
|
||||
directives : {},
|
||||
directive_stack : [],
|
||||
directives : Object.create(null),
|
||||
read_template : with_eof_error("Unterminated template literal", function(strings) {
|
||||
var s = "";
|
||||
for (;;) {
|
||||
|
@ -635,24 +634,19 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|||
};
|
||||
|
||||
next_token.add_directive = function(directive) {
|
||||
S.directive_stack[S.directive_stack.length - 1].push(directive);
|
||||
if (S.directives[directive]) S.directives[directive]++;
|
||||
else S.directives[directive] = 1;
|
||||
S.directives[directive] = true;
|
||||
}
|
||||
|
||||
next_token.push_directives_stack = function() {
|
||||
S.directive_stack.push([]);
|
||||
S.directives = Object.create(S.directives);
|
||||
}
|
||||
|
||||
next_token.pop_directives_stack = function() {
|
||||
var directives = S.directive_stack.pop();
|
||||
for (var i = directives.length; --i >= 0;) {
|
||||
S.directives[directives[i]]--;
|
||||
}
|
||||
S.directives = Object.getPrototypeOf(S.directives);
|
||||
}
|
||||
|
||||
next_token.has_directive = function(directive) {
|
||||
return S.directives[directive] > 0;
|
||||
return !!S.directives[directive];
|
||||
}
|
||||
|
||||
return next_token;
|
||||
|
@ -699,6 +693,7 @@ function parse($TEXT, options) {
|
|||
expression : false,
|
||||
filename : null,
|
||||
html5_comments : true,
|
||||
module : false,
|
||||
shebang : true,
|
||||
strict : false,
|
||||
toplevel : null,
|
||||
|
@ -1340,8 +1335,6 @@ function parse($TEXT, options) {
|
|||
var loop = S.in_loop;
|
||||
var labels = S.labels;
|
||||
++S.in_function;
|
||||
S.in_directives = true;
|
||||
S.input.push_directives_stack();
|
||||
S.in_loop = 0;
|
||||
S.labels = [];
|
||||
if (is("punc", "{")) {
|
||||
|
@ -1352,8 +1345,6 @@ function parse($TEXT, options) {
|
|||
handle_regexp();
|
||||
value = maybe_assign();
|
||||
}
|
||||
var is_strict = S.input.has_directive("use strict");
|
||||
S.input.pop_directives_stack();
|
||||
--S.in_function;
|
||||
S.in_loop = loop;
|
||||
S.labels = labels;
|
||||
|
@ -1367,7 +1358,7 @@ function parse($TEXT, options) {
|
|||
value: value,
|
||||
end: prev(),
|
||||
});
|
||||
if (is_strict) node.each_argname(strict_verify_symbol);
|
||||
if (S.input.has_directive("use strict")) node.each_argname(strict_verify_symbol);
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -1412,7 +1403,7 @@ function parse($TEXT, options) {
|
|||
name: name,
|
||||
argnames: argnames,
|
||||
rest: argnames.rest || null,
|
||||
body: body
|
||||
body: body,
|
||||
});
|
||||
if (is_strict) {
|
||||
if (name) strict_verify_symbol(name);
|
||||
|
@ -2550,6 +2541,7 @@ function parse($TEXT, options) {
|
|||
return function() {
|
||||
var start = S.token;
|
||||
var body = [];
|
||||
if (options.module) S.input.add_directive("use strict");
|
||||
S.input.push_directives_stack();
|
||||
while (!is("eof"))
|
||||
body.push(statement());
|
||||
|
|
24
node_modules/uglify-js/lib/scope.js
generated
vendored
24
node_modules/uglify-js/lib/scope.js
generated
vendored
|
@ -64,19 +64,20 @@ SymbolDef.prototype = {
|
|||
this.references.forEach(fn);
|
||||
},
|
||||
mangle: function(options) {
|
||||
var cache = options.cache && options.cache.props;
|
||||
if (this.global && cache && cache.has(this.name)) {
|
||||
if (this.mangled_name) return;
|
||||
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.mangled_name && !this.unmangleable(options)) {
|
||||
} else if (this.unmangleable(options)) {
|
||||
names_in_use(this.scope, options).set(this.name, true);
|
||||
} else {
|
||||
var def = this.redefined();
|
||||
if (def) {
|
||||
this.mangled_name = def.mangled_name || def.name;
|
||||
} else {
|
||||
this.mangled_name = next_mangled_name(this, options);
|
||||
}
|
||||
if (this.global && cache) {
|
||||
cache.set(this.name, this.mangled_name);
|
||||
}
|
||||
if (cache) cache.set(this.name, this.mangled_name);
|
||||
}
|
||||
},
|
||||
redefined: function() {
|
||||
|
@ -621,14 +622,10 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|||
var lname = -1;
|
||||
var redefined = [];
|
||||
var tw = new TreeWalker(function(node, descend) {
|
||||
if (node instanceof AST_LabeledStatement) {
|
||||
// `lname` is incremented when we get to the `AST_Label`
|
||||
var save_nesting = lname;
|
||||
descend();
|
||||
if (!options.v8 || !in_label(tw)) lname = save_nesting;
|
||||
return true;
|
||||
}
|
||||
var save_nesting;
|
||||
if (node instanceof AST_BlockScope) {
|
||||
// `lname` is incremented when we get to the `AST_Label`
|
||||
if (node instanceof AST_LabeledStatement) save_nesting = lname;
|
||||
if (options.webkit && node instanceof AST_IterationStatement && node.init instanceof AST_Let) {
|
||||
node.init.definitions.forEach(function(defn) {
|
||||
defn.name.match_symbol(function(sym) {
|
||||
|
@ -674,6 +671,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|||
}));
|
||||
}
|
||||
to_mangle.forEach(mangle);
|
||||
if (node instanceof AST_LabeledStatement && !(options.v8 && in_label(tw))) lname = save_nesting;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Label) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue