terser 5.19.2 → 5.19.4
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 +8 -0
- package/LICENSE +0 -2
- package/bin/terser.mjs +18 -0
- package/dist/bundle.min.js +42 -18
- package/lib/compress/drop-side-effect-free.js +12 -8
- package/lib/compress/drop-unused.js +0 -4
- package/lib/compress/index.js +0 -2
- package/lib/compress/inference.js +18 -7
- package/lib/compress/inline.js +4 -0
- package/lib/compress/reduce-vars.js +0 -4
- package/lib/compress/tighten-body.js +5 -1
- package/package.json +1 -1
- package/tools/domprops.js +1 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.19.4
|
4
|
+
- Prevent creating very deeply nested ternaries from a long list of `if..return`
|
5
|
+
- Prevent inlining classes into other functions, to avoid constructors being compared.
|
6
|
+
|
7
|
+
## v5.19.3
|
8
|
+
- Fix side effect detection of `optional?.chains`.
|
9
|
+
- Add roundRect to domprops.js (#1426)
|
10
|
+
|
3
11
|
## v5.19.2
|
4
12
|
- fix performance hit from avoiding HTML comments in the output
|
5
13
|
|
package/LICENSE
CHANGED
package/bin/terser.mjs
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
"use strict";
|
4
|
+
|
5
|
+
import "../tools/exit.cjs";
|
6
|
+
|
7
|
+
import fs from "fs";
|
8
|
+
import path from "path";
|
9
|
+
import program from "commander";
|
10
|
+
|
11
|
+
import { _run_cli as run_cli } from "../main.js";
|
12
|
+
|
13
|
+
const packageJson= JSON.parse( fs.readFileSync( new URL("./package.json", import.meta.url)));
|
14
|
+
|
15
|
+
run_cli({ program, packageJson, fs, path }).catch((error) => {
|
16
|
+
console.error(error);
|
17
|
+
process.exitCode = 1;
|
18
|
+
});
|
package/dist/bundle.min.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/source-map')) :
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/source-map'], factory) :
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
|
5
|
-
}
|
5
|
+
}(this, (function (exports, sourceMap) { 'use strict';
|
6
6
|
|
7
7
|
/***********************************************************************
|
8
8
|
|
@@ -13690,16 +13690,27 @@ function is_nullish(node, compressor) {
|
|
13690
13690
|
return any(this.elements, compressor);
|
13691
13691
|
});
|
13692
13692
|
def_has_side_effects(AST_Dot, function(compressor) {
|
13693
|
-
if (is_nullish(this, compressor))
|
13694
|
-
|
13695
|
-
|
13693
|
+
if (is_nullish(this, compressor)) {
|
13694
|
+
return this.expression.has_side_effects(compressor);
|
13695
|
+
}
|
13696
|
+
if (!this.optional && this.expression.may_throw_on_access(compressor)) {
|
13697
|
+
return true;
|
13698
|
+
}
|
13699
|
+
|
13700
|
+
return this.expression.has_side_effects(compressor);
|
13696
13701
|
});
|
13697
13702
|
def_has_side_effects(AST_Sub, function(compressor) {
|
13698
|
-
if (is_nullish(this, compressor))
|
13703
|
+
if (is_nullish(this, compressor)) {
|
13704
|
+
return this.expression.has_side_effects(compressor);
|
13705
|
+
}
|
13706
|
+
if (!this.optional && this.expression.may_throw_on_access(compressor)) {
|
13707
|
+
return true;
|
13708
|
+
}
|
13699
13709
|
|
13700
|
-
|
13701
|
-
|
13702
|
-
|
13710
|
+
var property = this.property.has_side_effects(compressor);
|
13711
|
+
if (property && this.optional) return true; // "?." is a condition
|
13712
|
+
|
13713
|
+
return property || this.expression.has_side_effects(compressor);
|
13703
13714
|
});
|
13704
13715
|
def_has_side_effects(AST_Chain, function (compressor) {
|
13705
13716
|
return this.expression.has_side_effects(compressor);
|
@@ -15039,7 +15050,9 @@ def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
|
|
15039
15050
|
if (is_nullish_shortcircuited(this, compressor)) {
|
15040
15051
|
return this.expression.drop_side_effect_free(compressor, first_in_statement);
|
15041
15052
|
}
|
15042
|
-
if (this.expression.may_throw_on_access(compressor))
|
15053
|
+
if (!this.optional && this.expression.may_throw_on_access(compressor)) {
|
15054
|
+
return this;
|
15055
|
+
}
|
15043
15056
|
|
15044
15057
|
return this.expression.drop_side_effect_free(compressor, first_in_statement);
|
15045
15058
|
});
|
@@ -15048,15 +15061,17 @@ def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
|
|
15048
15061
|
if (is_nullish_shortcircuited(this, compressor)) {
|
15049
15062
|
return this.expression.drop_side_effect_free(compressor, first_in_statement);
|
15050
15063
|
}
|
15051
|
-
if (this.expression.may_throw_on_access(compressor))
|
15064
|
+
if (!this.optional && this.expression.may_throw_on_access(compressor)) {
|
15065
|
+
return this;
|
15066
|
+
}
|
15052
15067
|
|
15053
|
-
var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
|
15054
|
-
if (!expression)
|
15055
|
-
return this.property.drop_side_effect_free(compressor, first_in_statement);
|
15056
15068
|
var property = this.property.drop_side_effect_free(compressor);
|
15057
|
-
if (
|
15058
|
-
|
15059
|
-
|
15069
|
+
if (property && this.optional) return this;
|
15070
|
+
|
15071
|
+
var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
|
15072
|
+
|
15073
|
+
if (expression && property) return make_sequence(this, [expression, property]);
|
15074
|
+
return expression || property;
|
15060
15075
|
});
|
15061
15076
|
|
15062
15077
|
def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
|
@@ -17147,7 +17162,11 @@ function tighten_body(statements, compressor) {
|
|
17147
17162
|
var self = compressor.self();
|
17148
17163
|
var multiple_if_returns = has_multiple_if_returns(statements);
|
17149
17164
|
var in_lambda = self instanceof AST_Lambda;
|
17150
|
-
|
17165
|
+
// Prevent extremely deep nesting
|
17166
|
+
// https://github.com/terser/terser/issues/1432
|
17167
|
+
// https://github.com/webpack/webpack/issues/17548
|
17168
|
+
const iteration_start = Math.min(statements.length, 500);
|
17169
|
+
for (var i = iteration_start; --i >= 0;) {
|
17151
17170
|
var stat = statements[i];
|
17152
17171
|
var j = next_index(i);
|
17153
17172
|
var next = statements[j];
|
@@ -17770,6 +17789,10 @@ function inline_into_symbolref(self, compressor) {
|
|
17770
17789
|
&& !fixed.may_throw(compressor);
|
17771
17790
|
}
|
17772
17791
|
|
17792
|
+
if (fixed instanceof AST_Class && def.scope !== self.scope) {
|
17793
|
+
return self;
|
17794
|
+
}
|
17795
|
+
|
17773
17796
|
if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
|
17774
17797
|
if (retain_top_func(fixed, compressor)) {
|
17775
17798
|
single_use = false;
|
@@ -28528,6 +28551,7 @@ var domprops = [
|
|
28528
28551
|
"rotationAngle",
|
28529
28552
|
"rotationRate",
|
28530
28553
|
"round",
|
28554
|
+
"roundRect",
|
28531
28555
|
"row-gap",
|
28532
28556
|
"rowGap",
|
28533
28557
|
"rowIndex",
|
@@ -30969,4 +30993,4 @@ exports._default_options = _default_options;
|
|
30969
30993
|
exports._run_cli = run_cli;
|
30970
30994
|
exports.minify = minify;
|
30971
30995
|
|
30972
|
-
}));
|
30996
|
+
})));
|
@@ -321,7 +321,9 @@ def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
|
|
321
321
|
if (is_nullish_shortcircuited(this, compressor)) {
|
322
322
|
return this.expression.drop_side_effect_free(compressor, first_in_statement);
|
323
323
|
}
|
324
|
-
if (this.expression.may_throw_on_access(compressor))
|
324
|
+
if (!this.optional && this.expression.may_throw_on_access(compressor)) {
|
325
|
+
return this;
|
326
|
+
}
|
325
327
|
|
326
328
|
return this.expression.drop_side_effect_free(compressor, first_in_statement);
|
327
329
|
});
|
@@ -330,15 +332,17 @@ def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
|
|
330
332
|
if (is_nullish_shortcircuited(this, compressor)) {
|
331
333
|
return this.expression.drop_side_effect_free(compressor, first_in_statement);
|
332
334
|
}
|
333
|
-
if (this.expression.may_throw_on_access(compressor))
|
335
|
+
if (!this.optional && this.expression.may_throw_on_access(compressor)) {
|
336
|
+
return this;
|
337
|
+
}
|
334
338
|
|
335
|
-
var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
|
336
|
-
if (!expression)
|
337
|
-
return this.property.drop_side_effect_free(compressor, first_in_statement);
|
338
339
|
var property = this.property.drop_side_effect_free(compressor);
|
339
|
-
if (
|
340
|
-
|
341
|
-
|
340
|
+
if (property && this.optional) return this;
|
341
|
+
|
342
|
+
var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
|
343
|
+
|
344
|
+
if (expression && property) return make_sequence(this, [expression, property]);
|
345
|
+
return expression || property;
|
342
346
|
});
|
343
347
|
|
344
348
|
def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
|
package/lib/compress/index.js
CHANGED
@@ -377,16 +377,27 @@ export function is_nullish(node, compressor) {
|
|
377
377
|
return any(this.elements, compressor);
|
378
378
|
});
|
379
379
|
def_has_side_effects(AST_Dot, function(compressor) {
|
380
|
-
if (is_nullish(this, compressor))
|
381
|
-
|
382
|
-
|
380
|
+
if (is_nullish(this, compressor)) {
|
381
|
+
return this.expression.has_side_effects(compressor);
|
382
|
+
}
|
383
|
+
if (!this.optional && this.expression.may_throw_on_access(compressor)) {
|
384
|
+
return true;
|
385
|
+
}
|
386
|
+
|
387
|
+
return this.expression.has_side_effects(compressor);
|
383
388
|
});
|
384
389
|
def_has_side_effects(AST_Sub, function(compressor) {
|
385
|
-
if (is_nullish(this, compressor))
|
390
|
+
if (is_nullish(this, compressor)) {
|
391
|
+
return this.expression.has_side_effects(compressor);
|
392
|
+
}
|
393
|
+
if (!this.optional && this.expression.may_throw_on_access(compressor)) {
|
394
|
+
return true;
|
395
|
+
}
|
386
396
|
|
387
|
-
|
388
|
-
|
389
|
-
|
397
|
+
var property = this.property.has_side_effects(compressor);
|
398
|
+
if (property && this.optional) return true; // "?." is a condition
|
399
|
+
|
400
|
+
return property || this.expression.has_side_effects(compressor);
|
390
401
|
});
|
391
402
|
def_has_side_effects(AST_Chain, function (compressor) {
|
392
403
|
return this.expression.has_side_effects(compressor);
|
package/lib/compress/inline.js
CHANGED
@@ -174,6 +174,10 @@ export function inline_into_symbolref(self, compressor) {
|
|
174
174
|
&& !fixed.may_throw(compressor);
|
175
175
|
}
|
176
176
|
|
177
|
+
if (fixed instanceof AST_Class && def.scope !== self.scope) {
|
178
|
+
return self;
|
179
|
+
}
|
180
|
+
|
177
181
|
if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
|
178
182
|
if (retain_top_func(fixed, compressor)) {
|
179
183
|
single_use = false;
|
@@ -981,7 +981,11 @@ export function tighten_body(statements, compressor) {
|
|
981
981
|
var self = compressor.self();
|
982
982
|
var multiple_if_returns = has_multiple_if_returns(statements);
|
983
983
|
var in_lambda = self instanceof AST_Lambda;
|
984
|
-
|
984
|
+
// Prevent extremely deep nesting
|
985
|
+
// https://github.com/terser/terser/issues/1432
|
986
|
+
// https://github.com/webpack/webpack/issues/17548
|
987
|
+
const iteration_start = Math.min(statements.length, 500);
|
988
|
+
for (var i = iteration_start; --i >= 0;) {
|
985
989
|
var stat = statements[i];
|
986
990
|
var j = next_index(i);
|
987
991
|
var next = statements[j];
|
package/package.json
CHANGED