terser 5.31.1 → 5.31.2

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.31.2
4
+ - drop_unused: scan variables in self-referential class declarations that contain side effects.
5
+ - Don't add parens to arrow function when it's the default for an argument (#1540)
6
+ - Update domprops (#1538)
7
+
3
8
  ## v5.31.1
4
9
  - Allow drop-unused to drop the whole assignment (not just the assigned name) in more situations, in order to avoid duplication of long strings.
5
10
 
@@ -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
- })(this, (function (exports, sourceMap) { 'use strict';
5
+ }(this, (function (exports, sourceMap) { 'use strict';
6
6
 
7
7
  /***********************************************************************
8
8
 
@@ -10276,7 +10276,9 @@ function OutputStream(options) {
10276
10276
  AST_Arrow.DEFMETHOD("_do_print", function(output) {
10277
10277
  var self = this;
10278
10278
  var parent = output.parent();
10279
- var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
10279
+ var needs_parens = (parent instanceof AST_Binary &&
10280
+ !(parent instanceof AST_Assign) &&
10281
+ !(parent instanceof AST_DefaultAssign)) ||
10280
10282
  parent instanceof AST_Unary ||
10281
10283
  (parent instanceof AST_Call && self === parent.expression);
10282
10284
  if (needs_parens) { output.print("("); }
@@ -15272,7 +15274,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
15272
15274
  }
15273
15275
  var var_defs_by_id = new Map();
15274
15276
  var initializations = new Map();
15275
- var self_referential_classes = new Set();
15276
15277
 
15277
15278
  // pass 1: find out which symbols are directly used in
15278
15279
  // this scope (not in nested scopes).
@@ -15287,8 +15288,11 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
15287
15288
  }
15288
15289
  if (node === self) return;
15289
15290
  if (node instanceof AST_Class && node.has_side_effects(compressor)) {
15290
- if (node.is_self_referential()) self_referential_classes.add(node);
15291
- node.visit_nondeferred_class_parts(tw);
15291
+ if (node.is_self_referential()) {
15292
+ descend();
15293
+ } else {
15294
+ node.visit_nondeferred_class_parts(tw);
15295
+ }
15292
15296
  }
15293
15297
  if (node instanceof AST_Defun || node instanceof AST_DefClass) {
15294
15298
  var node_def = node.name.definition();
@@ -15352,9 +15356,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
15352
15356
  init.walk(tw);
15353
15357
  });
15354
15358
  });
15355
- self_referential_classes.forEach(function (cls) {
15356
- cls.walk(tw);
15357
- });
15358
15359
  // pass 3: we should drop declarations not in_use
15359
15360
  var tt = new TreeTransformer(
15360
15361
  function before(node, descend, in_list) {
@@ -30779,6 +30780,7 @@ var domprops = [
30779
30780
  "uint32",
30780
30781
  "uint8",
30781
30782
  "uint8Clamped",
30783
+ "unadjustedMovement",
30782
30784
  "unclippedDepth",
30783
30785
  "unconfigure",
30784
30786
  "undefined",
@@ -32539,4 +32541,4 @@ exports._run_cli = run_cli;
32539
32541
  exports.minify = minify;
32540
32542
  exports.minify_sync = minify_sync;
32541
32543
 
32542
- }));
32544
+ })));
@@ -139,7 +139,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
139
139
  }
140
140
  var var_defs_by_id = new Map();
141
141
  var initializations = new Map();
142
- var self_referential_classes = new Set();
143
142
 
144
143
  // pass 1: find out which symbols are directly used in
145
144
  // this scope (not in nested scopes).
@@ -154,8 +153,11 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
154
153
  }
155
154
  if (node === self) return;
156
155
  if (node instanceof AST_Class && node.has_side_effects(compressor)) {
157
- if (node.is_self_referential()) self_referential_classes.add(node);
158
- node.visit_nondeferred_class_parts(tw);
156
+ if (node.is_self_referential()) {
157
+ descend();
158
+ } else {
159
+ node.visit_nondeferred_class_parts(tw);
160
+ }
159
161
  }
160
162
  if (node instanceof AST_Defun || node instanceof AST_DefClass) {
161
163
  var node_def = node.name.definition();
@@ -219,9 +221,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
219
221
  init.walk(tw);
220
222
  });
221
223
  });
222
- self_referential_classes.forEach(function (cls) {
223
- cls.walk(tw);
224
- });
225
224
  // pass 3: we should drop declarations not in_use
226
225
  var tt = new TreeTransformer(
227
226
  function before(node, descend, in_list) {
package/lib/output.js CHANGED
@@ -1501,7 +1501,9 @@ function OutputStream(options) {
1501
1501
  AST_Arrow.DEFMETHOD("_do_print", function(output) {
1502
1502
  var self = this;
1503
1503
  var parent = output.parent();
1504
- var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
1504
+ var needs_parens = (parent instanceof AST_Binary &&
1505
+ !(parent instanceof AST_Assign) &&
1506
+ !(parent instanceof AST_DefaultAssign)) ||
1505
1507
  parent instanceof AST_Unary ||
1506
1508
  (parent instanceof AST_Call && self === parent.expression);
1507
1509
  if (needs_parens) { output.print("("); }
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.31.1",
7
+ "version": "5.31.2",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },
package/tools/domprops.js CHANGED
@@ -8225,6 +8225,7 @@ export var domprops = [
8225
8225
  "uint32",
8226
8226
  "uint8",
8227
8227
  "uint8Clamped",
8228
+ "unadjustedMovement",
8228
8229
  "unclippedDepth",
8229
8230
  "unconfigure",
8230
8231
  "undefined",