terser 3.10.13 → 3.11.0

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.

Potentially problematic release.


This version of terser might be problematic. Click here for more details.

package/lib/compress.js CHANGED
@@ -4556,8 +4556,8 @@ merge(Compressor.prototype, {
4556
4556
 
4557
4557
  function retain_top_func(fn, compressor) {
4558
4558
  return compressor.top_retain
4559
- && fn._top
4560
4559
  && fn instanceof AST_Defun
4560
+ && fn._top
4561
4561
  && fn.name
4562
4562
  && compressor.top_retain(fn.name);
4563
4563
  }
@@ -4902,7 +4902,8 @@ merge(Compressor.prototype, {
4902
4902
  && fn.is_constant_expression(exp.scope))
4903
4903
  && !self.pure
4904
4904
  && !fn.contains_this()
4905
- && can_inject_symbols()) {
4905
+ && can_inject_symbols()
4906
+ && !(scope instanceof AST_Class)) {
4906
4907
  fn._squeezed = true;
4907
4908
  return make_sequence(self, flatten_fn()).optimize(compressor);
4908
4909
  }
package/lib/scope.js CHANGED
@@ -60,12 +60,15 @@ function SymbolDef(scope, orig, init) {
60
60
 
61
61
  SymbolDef.next_id = 1;
62
62
 
63
+ var MASK_EXPORT_DONT_MANGLE = 1 << 0;
64
+ var MASK_EXPORT_WANT_MANGLE = 1 << 1;
65
+
63
66
  SymbolDef.prototype = {
64
67
  unmangleable: function(options) {
65
68
  if (!options) options = {};
66
69
 
67
70
  return this.global && !options.toplevel
68
- || this.export
71
+ || (this.export & MASK_EXPORT_DONT_MANGLE)
69
72
  || this.undeclared
70
73
  || !options.eval && this.scope.pinned()
71
74
  || (this.orig[0] instanceof AST_SymbolLambda
@@ -252,7 +255,12 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
252
255
  } while (tw.parent(i++) !== in_destructuring);
253
256
  }
254
257
  var node = tw.parent(level);
255
- def.export = node instanceof AST_Export;
258
+ if (def.export = node instanceof AST_Export && MASK_EXPORT_DONT_MANGLE) {
259
+ var exported = node.exported_definition;
260
+ if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
261
+ def.export = MASK_EXPORT_WANT_MANGLE;
262
+ }
263
+ }
256
264
  }
257
265
  });
258
266
  self.walk(tw);
@@ -275,7 +283,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
275
283
  if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
276
284
  || !(sym = node.scope.find_variable(name))) {
277
285
  sym = self.def_global(node);
278
- if (node instanceof AST_SymbolExport) sym.export = node.TYPE;
286
+ if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
279
287
  } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
280
288
  sym.scope.uses_arguments = true;
281
289
  }
@@ -571,7 +579,9 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
571
579
 
572
580
  function collect(symbol) {
573
581
  if (!member(symbol.name, options.reserved)) {
574
- if (!symbol.export) to_mangle.push(symbol);
582
+ if (!(symbol.export & MASK_EXPORT_DONT_MANGLE)) {
583
+ to_mangle.push(symbol);
584
+ }
575
585
  }
576
586
  }
577
587
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://github.com/fabiosantoscode/terser",
5
5
  "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
6
6
  "license": "BSD-2-Clause",
7
- "version": "3.10.13",
7
+ "version": "3.11.0",
8
8
  "engines": {
9
9
  "node": ">=0.8.0"
10
10
  },