terser 4.3.5 → 4.3.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## v4.3.9
4
+ - Fixed issue with mangle's `keep_fnames` option, introduced when adding code to keep variable names of anonymous functions
5
+
6
+ ## v4.3.8
7
+
8
+ - Typescript typings fix
9
+
10
+ ## v4.3.7
11
+
12
+ - Parsing of regex options in the CLI (which broke in v4.3.5) was fixed.
13
+ - typescript definition updates
14
+
15
+ ## v4.3.6
16
+
17
+ (crash hotfix)
18
+
3
19
  ## v4.3.5
4
20
 
5
21
  - Fixed an issue with DOS line endings strings separated by `\` and a new line.
package/README.md CHANGED
@@ -261,7 +261,7 @@ way to use this is to use the `regex` option like so:
261
261
  terser example.js -c -m --mangle-props regex=/_$/
262
262
  ```
263
263
 
264
- This will mangle all properties that start with an
264
+ This will mangle all properties that end with an
265
265
  underscore. So you can use it to mangle internal methods.
266
266
 
267
267
  By default, it will mangle all properties in the
@@ -289,32 +289,32 @@ console.log(x.calc());
289
289
  ```
290
290
  Mangle all properties (except for JavaScript `builtins`) (**very** unsafe):
291
291
  ```bash
292
- $ terser example.js -c -m --mangle-props
292
+ $ terser example.js -c passes=2 -m --mangle-props
293
293
  ```
294
294
  ```javascript
295
- var x={o:0,_:1,l:function(){return this._+this.o}};x.t=2,x.o=3,console.log(x.l());
295
+ var x={o:3,t:1,i:function(){return this.t+this.o},s:2};console.log(x.i());
296
296
  ```
297
297
  Mangle all properties except for `reserved` properties (still very unsafe):
298
298
  ```bash
299
- $ terser example.js -c -m --mangle-props reserved=[foo_,bar_]
299
+ $ terser example.js -c passes=2 -m --mangle-props reserved=[foo_,bar_]
300
300
  ```
301
301
  ```javascript
302
- var x={o:0,foo_:1,_:function(){return this.foo_+this.o}};x.bar_=2,x.o=3,console.log(x._());
302
+ var x={o:3,foo_:1,t:function(){return this.foo_+this.o},bar_:2};console.log(x.t());
303
303
  ```
304
304
  Mangle all properties matching a `regex` (not as unsafe but still unsafe):
305
305
  ```bash
306
- $ terser example.js -c -m --mangle-props regex=/_$/
306
+ $ terser example.js -c passes=2 -m --mangle-props regex=/_$/
307
307
  ```
308
308
  ```javascript
309
- var x={o:0,_:1,calc:function(){return this._+this.o}};x.l=2,x.o=3,console.log(x.calc());
309
+ var x={o:3,t:1,calc:function(){return this.t+this.o},i:2};console.log(x.calc());
310
310
  ```
311
311
 
312
312
  Combining mangle properties options:
313
313
  ```bash
314
- $ terser example.js -c -m --mangle-props regex=/_$/,reserved=[bar_]
314
+ $ terser example.js -c passes=2 -m --mangle-props regex=/_$/,reserved=[bar_]
315
315
  ```
316
316
  ```javascript
317
- var x={o:0,_:1,calc:function(){return this._+this.o}};x.bar_=2,x.o=3,console.log(x.calc());
317
+ var x={o:3,t:1,calc:function(){return this.t+this.o},bar_:2};console.log(x.calc());
318
318
  ```
319
319
 
320
320
  In order for this to be of any use, we avoid mangling standard JS names by
@@ -820,7 +820,7 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
820
820
  case a value of `20` or less is recommended.
821
821
 
822
822
  - `side_effects` (default: `true`) -- Pass `false` to disable potentially dropping
823
- functions marked as "pure". A function call is marked as "pure" if a comment
823
+ function calls marked as "pure". A function call is marked as "pure" if a comment
824
824
  annotation `/*@__PURE__*/` or `/*#__PURE__*/` immediately precedes the call. For
825
825
  example: `/*@__PURE__*/foo();`
826
826
 
package/bin/terser CHANGED
@@ -368,6 +368,9 @@ function parse_js(flag) {
368
368
  options[name] = value;
369
369
  } else if (value instanceof Terser.AST_Array) {
370
370
  options[name] = value.elements.map(to_string);
371
+ } else if (value instanceof Terser.AST_RegExp) {
372
+ value = value.value;
373
+ options[name] = new RegExp(value.source, value.flags);
371
374
  } else {
372
375
  options[name] = to_string(value);
373
376
  }