terser 5.3.3 → 5.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/bundle.min.js +61 -16
- package/dist/bundle.min.js.map +1 -1
- package/lib/compress/index.js +26 -15
- package/lib/output.js +4 -0
- package/lib/scope.js +27 -1
- package/lib/transform.js +5 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.3.7
|
4
|
+
|
5
|
+
Hotfix release, fixes package.json "engines" syntax
|
6
|
+
|
7
|
+
## v5.3.6
|
8
|
+
|
9
|
+
- Fixed parentheses when outputting `??` mixed with `||` and `&&`
|
10
|
+
- Improved hygiene of the symbol generator
|
11
|
+
|
12
|
+
## v5.3.5
|
13
|
+
|
14
|
+
- Avoid moving named functions into default exports.
|
15
|
+
- Enabled transform() for chain expressions. This allows AST transformers to reach inside chain expressions.
|
16
|
+
|
17
|
+
## v5.3.4
|
18
|
+
|
19
|
+
- Fixed a crash when hoisting (with `hoist_vars`) a destructuring variable declaration
|
20
|
+
|
3
21
|
## v5.3.3
|
4
22
|
|
5
23
|
- `source-map` library has been updated, bringing memory usage and CPU time improvements when reading input source maps (the SourceMapConsumer is now WASM based).
|
package/dist/bundle.min.js
CHANGED
@@ -5363,6 +5363,10 @@ def_transform(AST_Sub, function(self, tw) {
|
|
5363
5363
|
self.property = self.property.transform(tw);
|
5364
5364
|
});
|
5365
5365
|
|
5366
|
+
def_transform(AST_Chain, function(self, tw) {
|
5367
|
+
self.expression = self.expression.transform(tw);
|
5368
|
+
});
|
5369
|
+
|
5366
5370
|
def_transform(AST_Yield, function(self, tw) {
|
5367
5371
|
if (self.expression) self.expression = self.expression.transform(tw);
|
5368
5372
|
});
|
@@ -7500,6 +7504,10 @@ function OutputStream(options) {
|
|
7500
7504
|
return true;
|
7501
7505
|
}
|
7502
7506
|
|
7507
|
+
if (po === "??" && (so === "||" || so === "&&")) {
|
7508
|
+
return true;
|
7509
|
+
}
|
7510
|
+
|
7503
7511
|
const pp = PRECEDENCE[po];
|
7504
7512
|
const sp = PRECEDENCE[so];
|
7505
7513
|
if (pp > sp
|
@@ -9409,6 +9417,13 @@ AST_Scope.DEFMETHOD("conflicting_def", function (name) {
|
|
9409
9417
|
);
|
9410
9418
|
});
|
9411
9419
|
|
9420
|
+
AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
|
9421
|
+
return (
|
9422
|
+
this.enclosed.find(def => def.name === name)
|
9423
|
+
|| this.variables.has(name)
|
9424
|
+
);
|
9425
|
+
});
|
9426
|
+
|
9412
9427
|
AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
|
9413
9428
|
// `scope` is going to be moved into `this` right now.
|
9414
9429
|
// Update the required scopes' information
|
@@ -9442,15 +9457,34 @@ AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
|
|
9442
9457
|
}
|
9443
9458
|
});
|
9444
9459
|
|
9460
|
+
function find_scopes_visible_from(scopes) {
|
9461
|
+
const found_scopes = new Set();
|
9462
|
+
|
9463
|
+
for (const scope of new Set(scopes)) {
|
9464
|
+
(function bubble_up(scope) {
|
9465
|
+
if (scope == null || found_scopes.has(scope)) return;
|
9466
|
+
|
9467
|
+
found_scopes.add(scope);
|
9468
|
+
|
9469
|
+
bubble_up(scope.parent_scope);
|
9470
|
+
})(scope);
|
9471
|
+
}
|
9472
|
+
|
9473
|
+
return [...found_scopes];
|
9474
|
+
}
|
9475
|
+
|
9445
9476
|
// Creates a symbol during compression
|
9446
9477
|
AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
|
9447
9478
|
source,
|
9448
9479
|
tentative_name,
|
9449
9480
|
scope,
|
9481
|
+
conflict_scopes = [scope],
|
9450
9482
|
init = null
|
9451
9483
|
} = {}) {
|
9452
9484
|
let symbol_name;
|
9453
9485
|
|
9486
|
+
conflict_scopes = find_scopes_visible_from(conflict_scopes);
|
9487
|
+
|
9454
9488
|
if (tentative_name) {
|
9455
9489
|
// Implement hygiene (no new names are conflicting with existing names)
|
9456
9490
|
tentative_name =
|
@@ -9458,7 +9492,7 @@ AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
|
|
9458
9492
|
tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
|
9459
9493
|
|
9460
9494
|
let i = 0;
|
9461
|
-
while (
|
9495
|
+
while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
|
9462
9496
|
symbol_name = tentative_name + "$" + i++;
|
9463
9497
|
}
|
9464
9498
|
}
|
@@ -14242,9 +14276,12 @@ AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
|
|
14242
14276
|
hoisted.push(node);
|
14243
14277
|
return make_node(AST_EmptyStatement, node);
|
14244
14278
|
}
|
14245
|
-
if (
|
14279
|
+
if (
|
14280
|
+
hoist_vars
|
14281
|
+
&& node instanceof AST_Var
|
14282
|
+
&& !node.definitions.some(def => def.name instanceof AST_Destructuring)
|
14283
|
+
) {
|
14246
14284
|
node.definitions.forEach(function(def) {
|
14247
|
-
if (def.name instanceof AST_Destructuring) return;
|
14248
14285
|
vars.set(def.name.name, def);
|
14249
14286
|
++vars_found;
|
14250
14287
|
});
|
@@ -14324,8 +14361,7 @@ AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
|
|
14324
14361
|
continue;
|
14325
14362
|
}
|
14326
14363
|
if (self.body[i] instanceof AST_BlockStatement) {
|
14327
|
-
|
14328
|
-
self.body.splice.apply(self.body, tmp);
|
14364
|
+
self.body.splice(i, 1, ...self.body[i].body);
|
14329
14365
|
continue;
|
14330
14366
|
}
|
14331
14367
|
break;
|
@@ -14370,9 +14406,14 @@ AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
|
|
14370
14406
|
const defs = new Map();
|
14371
14407
|
const assignments = [];
|
14372
14408
|
value.properties.forEach(({ key, value }) => {
|
14409
|
+
const scope = find_scope(hoister);
|
14373
14410
|
const symbol = self.create_symbol(sym.CTOR, {
|
14374
14411
|
source: sym,
|
14375
|
-
scope
|
14412
|
+
scope,
|
14413
|
+
conflict_scopes: new Set([
|
14414
|
+
scope,
|
14415
|
+
...sym.definition().references.map(ref => ref.scope)
|
14416
|
+
]),
|
14376
14417
|
tentative_name: sym.name + "_" + key
|
14377
14418
|
});
|
14378
14419
|
|
@@ -15071,10 +15112,12 @@ AST_Definitions.DEFMETHOD("remove_initializers", function() {
|
|
15071
15112
|
|
15072
15113
|
AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
|
15073
15114
|
var reduce_vars = compressor.option("reduce_vars");
|
15074
|
-
var assignments =
|
15075
|
-
|
15115
|
+
var assignments = [];
|
15116
|
+
|
15117
|
+
for (const def of this.definitions) {
|
15118
|
+
if (def.value) {
|
15076
15119
|
var name = make_node(AST_SymbolRef, def.name, def.name);
|
15077
|
-
|
15120
|
+
assignments.push(make_node(AST_Assign, def, {
|
15078
15121
|
operator : "=",
|
15079
15122
|
left : name,
|
15080
15123
|
right : def.value
|
@@ -15089,13 +15132,13 @@ AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
|
|
15089
15132
|
var var_ = make_node(AST_Var, def, {
|
15090
15133
|
definitions: [ varDef ]
|
15091
15134
|
});
|
15092
|
-
|
15135
|
+
assignments.push(var_);
|
15093
15136
|
}
|
15094
|
-
|
15095
|
-
|
15096
|
-
|
15097
|
-
|
15098
|
-
|
15137
|
+
const thedef = def.name.definition();
|
15138
|
+
thedef.eliminated++;
|
15139
|
+
thedef.replaced--;
|
15140
|
+
}
|
15141
|
+
|
15099
15142
|
if (assignments.length == 0) return null;
|
15100
15143
|
return make_sequence(this, assignments);
|
15101
15144
|
});
|
@@ -16465,7 +16508,9 @@ def_optimize(AST_SymbolRef, function(self, compressor) {
|
|
16465
16508
|
&& !(parent instanceof AST_Call
|
16466
16509
|
&& (parent.is_expr_pure(compressor))
|
16467
16510
|
|| has_annotation(parent, _NOINLINE))
|
16468
|
-
&& !(
|
16511
|
+
&& !(parent instanceof AST_Export
|
16512
|
+
&& fixed instanceof AST_Lambda
|
16513
|
+
&& fixed.name);
|
16469
16514
|
|
16470
16515
|
if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
|
16471
16516
|
if (retain_top_func(fixed, compressor)) {
|