terser 5.3.4 → 5.3.8
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 +44 -3
- package/dist/bundle.min.js.map +1 -1
- package/lib/compress/index.js +9 -2
- package/lib/output.js +4 -0
- package/lib/scope.js +27 -1
- package/lib/transform.js +5 -0
- package/package.json +11 -12
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.3.8
|
4
|
+
|
5
|
+
- Restore node 13 support
|
6
|
+
|
7
|
+
## v5.3.7
|
8
|
+
|
9
|
+
Hotfix release, fixes package.json "engines" syntax
|
10
|
+
|
11
|
+
## v5.3.6
|
12
|
+
|
13
|
+
- Fixed parentheses when outputting `??` mixed with `||` and `&&`
|
14
|
+
- Improved hygiene of the symbol generator
|
15
|
+
|
16
|
+
## v5.3.5
|
17
|
+
|
18
|
+
- Avoid moving named functions into default exports.
|
19
|
+
- Enabled transform() for chain expressions. This allows AST transformers to reach inside chain expressions.
|
20
|
+
|
3
21
|
## v5.3.4
|
4
22
|
|
5
23
|
- Fixed a crash when hoisting (with `hoist_vars`) a destructuring variable declaration
|
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
|
}
|
@@ -14372,9 +14406,14 @@ AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
|
|
14372
14406
|
const defs = new Map();
|
14373
14407
|
const assignments = [];
|
14374
14408
|
value.properties.forEach(({ key, value }) => {
|
14409
|
+
const scope = find_scope(hoister);
|
14375
14410
|
const symbol = self.create_symbol(sym.CTOR, {
|
14376
14411
|
source: sym,
|
14377
|
-
scope
|
14412
|
+
scope,
|
14413
|
+
conflict_scopes: new Set([
|
14414
|
+
scope,
|
14415
|
+
...sym.definition().references.map(ref => ref.scope)
|
14416
|
+
]),
|
14378
14417
|
tentative_name: sym.name + "_" + key
|
14379
14418
|
});
|
14380
14419
|
|
@@ -16469,7 +16508,9 @@ def_optimize(AST_SymbolRef, function(self, compressor) {
|
|
16469
16508
|
&& !(parent instanceof AST_Call
|
16470
16509
|
&& (parent.is_expr_pure(compressor))
|
16471
16510
|
|| has_annotation(parent, _NOINLINE))
|
16472
|
-
&& !(
|
16511
|
+
&& !(parent instanceof AST_Export
|
16512
|
+
&& fixed instanceof AST_Lambda
|
16513
|
+
&& fixed.name);
|
16473
16514
|
|
16474
16515
|
if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
|
16475
16516
|
if (retain_top_func(fixed, compressor)) {
|