terser 5.19.3 → 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 CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  ## v5.19.3
4
8
  - Fix side effect detection of `optional?.chains`.
5
9
  - Add roundRect to domprops.js (#1426)
@@ -17162,7 +17162,11 @@ function tighten_body(statements, compressor) {
17162
17162
  var self = compressor.self();
17163
17163
  var multiple_if_returns = has_multiple_if_returns(statements);
17164
17164
  var in_lambda = self instanceof AST_Lambda;
17165
- for (var i = statements.length; --i >= 0;) {
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;) {
17166
17170
  var stat = statements[i];
17167
17171
  var j = next_index(i);
17168
17172
  var next = statements[j];
@@ -17785,6 +17789,10 @@ function inline_into_symbolref(self, compressor) {
17785
17789
  && !fixed.may_throw(compressor);
17786
17790
  }
17787
17791
 
17792
+ if (fixed instanceof AST_Class && def.scope !== self.scope) {
17793
+ return self;
17794
+ }
17795
+
17788
17796
  if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
17789
17797
  if (retain_top_func(fixed, compressor)) {
17790
17798
  single_use = false;
@@ -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
- for (var i = statements.length; --i >= 0;) {
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
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://terser.org",
5
5
  "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
6
6
  "license": "BSD-2-Clause",
7
- "version": "5.19.3",
7
+ "version": "5.19.4",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },