terser 5.6.0 → 5.7.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,51 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.7.2
4
+
5
+ - Fixed issues with compressing functions defined in `global_defs` option (#1036)
6
+ - New recipe for using Terser in gulp was added to RECIPES.md (#1035)
7
+ - Fixed issues with `??` and `?.` (#1045)
8
+ - Future reserved words such as `package` no longer require you to disable strict mode to be used as names.
9
+ - Refactored huge compressor file into multiple more focused files.
10
+ - Avoided unparenthesized `in` operator in some for loops (it breaks parsing because of for..in loops)
11
+ - Improved documentation (#1021, #1025)
12
+ - More type definitions (#1021)
13
+
14
+ ## v5.7.1
15
+
16
+ - Avoided collapsing assignments together if it would place a chain assignment on the left hand side, which is invalid syntax (`a?.b = c`)
17
+ - Removed undefined from object expansions (`{ ...void 0 }` -> `{}`)
18
+ - Fix crash when checking if something is nullish or undefined (#1009)
19
+ - Fixed comparison of private class properties (#1015)
20
+ - Minor performance improvements (#993)
21
+ - Fixed scope of function defs in strict mode (they are block scoped)
22
+
23
+ ## v5.7.0
24
+
25
+ - Several compile-time evaluation and inlining fixes
26
+ - Allow `reduce_funcs` to be disabled again.
27
+ - Add `spidermonkey` options to parse and format (#974)
28
+ - Accept `{get = "default val"}` and `{set = "default val"}` in destructuring arguments.
29
+ - Change package.json export map to help require.resolve (#971)
30
+ - Improve docs
31
+ - Fix `export default` of an anonymous class with `extends`
32
+
33
+ ## v5.6.1
34
+
35
+ - Mark assignments to the `.prototype` of a class as pure
36
+ - Parenthesize `await` on the left of `**` (while accepting legacy non-parenthesised input)
37
+ - Avoided outputting NUL bytes in optimized RegExps, to stop the output from breaking other tools
38
+ - Added `exports` to domprops (#939)
39
+ - Fixed a crash when spreading `...this`
40
+ - Fixed the computed size of arrow functions, which improves their inlining
41
+
42
+ ## v5.6.0
43
+
44
+ - Added top-level await
45
+ - Beautify option has been removed in #895
46
+ - Private properties, getters and setters have been added in #913 and some more commits
47
+ - Docs improvements: #896, #903, #916
48
+
3
49
  ## v5.5.1
4
50
 
5
51
  - Fixed object properties with unicode surrogates on safari.
package/README.md CHANGED
@@ -21,8 +21,8 @@ Find the changelog in [CHANGELOG.md](https://github.com/terser/terser/blob/maste
21
21
  [npm-url]: https://npmjs.org/package/terser
22
22
  [downloads-image]: https://img.shields.io/npm/dm/terser.svg
23
23
  [downloads-url]: https://npmjs.org/package/terser
24
- [travis-image]: https://img.shields.io/travis/terser/terser/master.svg
25
- [travis-url]: https://travis-ci.org/terser/terser
24
+ [travis-image]: https://travis-ci.com/terser/terser.svg?branch=master
25
+ [travis-url]: https://travis-ci.com/terser/terser
26
26
  [opencollective-contributors]: https://opencollective.com/terser/tiers/badge.svg
27
27
  [opencollective-url]: https://opencollective.com/terser
28
28
 
@@ -416,7 +416,7 @@ Browser loading is also supported:
416
416
 
417
417
  There is a single async high level function, **`async minify(code, options)`**,
418
418
  which will perform all minification [phases](#minify-options) in a configurable
419
- manner. There is no synchronous function, but this functionality can be achieved with a package like [deasync](https://github.com/abbr/deasync). By default `minify()` will enable the options [`compress`](#compress-options)
419
+ manner. By default `minify()` will enable [`compress`](#compress-options)
420
420
  and [`mangle`](#mangle-options). Example:
421
421
  ```javascript
422
422
  var code = "function add(first, second) { return first + second; }";
@@ -530,6 +530,11 @@ try {
530
530
  - `ecma` (default `undefined`) - pass `5`, `2015`, `2016`, etc to override
531
531
  `compress` and `format`'s `ecma` options.
532
532
 
533
+ - `enclose` (default `false`) - pass `true`, or a string in the format
534
+ of `"args[:values]"`, where `args` and `values` are comma-separated
535
+ argument names and values, respectively, to embed the output in a big
536
+ function with the configurable arguments and values.
537
+
533
538
  - `parse` (default `{}`) — pass an object if you wish to specify some
534
539
  additional [parse options](#parse-options).
535
540
 
@@ -569,7 +574,7 @@ try {
569
574
  of class names. Pass a regular expression to only keep class names matching that regex.
570
575
 
571
576
  - `keep_fnames` (default: `false`) - pass `true` to prevent discarding or mangling
572
- of function names. Pass a regular expression to only keep class names matching that regex.
577
+ of function names. Pass a regular expression to only keep function names matching that regex.
573
578
  Useful for code relying on `Function.prototype.name`. If the top level minify option
574
579
  `keep_classnames` is `undefined` it will be overridden with the value of the top level
575
580
  minify option `keep_fnames`.
@@ -602,13 +607,14 @@ try {
602
607
  // source map options
603
608
  },
604
609
  ecma: 5, // specify one of: 5, 2015, 2016, etc.
610
+ enclose: false, // or specify true, or "args:values"
605
611
  keep_classnames: false,
606
612
  keep_fnames: false,
607
613
  ie8: false,
608
614
  module: false,
609
615
  nameCache: null, // or specify a name cache object
610
616
  safari10: false,
611
- toplevel: false,
617
+ toplevel: false
612
618
  }
613
619
  ```
614
620
 
@@ -669,6 +675,8 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
669
675
 
670
676
  - `shebang` (default `true`) -- support `#!command` as the first line
671
677
 
678
+ - `spidermonkey` (default `false`) -- accept a Spidermonkey (Mozilla) AST
679
+
672
680
  ## Compress options
673
681
 
674
682
  - `defaults` (default: `true`) -- Pass `false` to disable most default
@@ -795,11 +803,13 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
795
803
  Specify `"strict"` to treat `foo.bar` as side-effect-free only when
796
804
  `foo` is certain to not throw, i.e. not `null` or `undefined`.
797
805
 
798
- - `reduce_funcs` (legacy option, safely ignored for backwards compatibility).
799
-
800
806
  - `reduce_vars` (default: `true`) -- Improve optimization on variables assigned with and
801
807
  used as constant values.
802
808
 
809
+ - `reduce_funcs` (default: `true`) -- Inline single-use functions when
810
+ possible. Depends on `reduce_vars` being enabled. Disabling this option
811
+ sometimes improves performance of the output code.
812
+
803
813
  - `sequences` (default: `true`) -- join consecutive simple statements using the
804
814
  comma operator. May be set to a positive integer to specify the maximum number
805
815
  of consecutive comma sequences that will be generated. If this option is set to
@@ -848,7 +858,7 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
848
858
  - `unsafe_math` (default: `false`) -- optimize numerical expressions like
849
859
  `2 * x * 3` into `6 * x`, which may give imprecise floating point results.
850
860
 
851
- - `unsafe_symbols` (default: `false`) -- removes keys from native Symbol
861
+ - `unsafe_symbols` (default: `false`) -- removes keys from native Symbol
852
862
  declarations, e.g `Symbol("kDog")` becomes `Symbol()`.
853
863
 
854
864
  - `unsafe_methods` (default: false) -- Converts `{ m: function(){} }` to
@@ -881,7 +891,7 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
881
891
  See also: the `keep_classnames` [compress option](#compress-options).
882
892
 
883
893
  - `keep_fnames` (default `false`) -- Pass `true` to not mangle function names.
884
- Pass a regular expression to only keep class names matching that regex.
894
+ Pass a regular expression to only keep function names matching that regex.
885
895
  Useful for code relying on `Function.prototype.name`. See also: the `keep_fnames`
886
896
  [compress option](#compress-options).
887
897
 
@@ -929,11 +939,10 @@ await minify(code, { mangle: { toplevel: true } }).code;
929
939
  - `debug` (default: `false`) — Mangle names with the original name still present.
930
940
  Pass an empty string `""` to enable, or a non-empty string to set the debug suffix.
931
941
 
932
- - `keep_quoted` (default: `false`) — Only mangle unquoted property names.
933
- - `true` -- Quoted property names are automatically reserved and any unquoted
934
- property names will not be mangled.
935
- - `"strict"` -- Advanced, all unquoted property names are mangled unless
936
- explicitly reserved.
942
+ - `keep_quoted` (default: `false`) — How quoting properties (`{"prop": ...}` and `obj["prop"]`) controls what gets mangled.
943
+ - `"strict"` (recommended) -- `obj.prop` is mangled.
944
+ - `false` -- `obj["prop"]` is mangled.
945
+ - `true` -- `obj.prop` is mangled unless there is `obj["prop"]` elsewhere in the code.
937
946
 
938
947
  - `regex` (default: `null`) — Pass a [RegExp literal or pattern string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) to only mangle property matching the regular expression.
939
948
 
@@ -954,19 +963,17 @@ as "output options".
954
963
  - `ascii_only` (default `false`) -- escape Unicode characters in strings and
955
964
  regexps (affects directives with non-ascii characters becoming invalid)
956
965
 
957
- - `beautify` (default `false`) -- whether to actually beautify the output.
958
- Passing `-b` will set this to true, but you might need to pass `-b` even
959
- when you want to generate minified code, in order to specify additional
960
- arguments, so you can use `-b beautify=false` to override it.
966
+ - `beautify` (default `false`) -- (DEPRECATED) whether to beautify the output.
967
+ When using the legacy `-b` CLI flag, this is set to true by default.
961
968
 
962
969
  - `braces` (default `false`) -- always insert braces in `if`, `for`,
963
970
  `do`, `while` or `with` statements, even if their body is a single
964
971
  statement.
965
972
 
966
973
  - `comments` (default `"some"`) -- by default it keeps JSDoc-style comments
967
- that contain "@license" or "@preserve", pass `true` or `"all"` to preserve all
968
- comments, `false` to omit comments in the output, a regular expression string
969
- (e.g. `/^!/`) or a function.
974
+ that contain "@license", "@preserve" or start with `!`, pass `true` or
975
+ `"all"` to preserve all comments, `false` to omit comments in the output,
976
+ a regular expression string (e.g. `/^!/`) or a function.
970
977
 
971
978
  - `ecma` (default `5`) -- set desired EcmaScript standard version for output.
972
979
  Set `ecma` to `2015` or greater to emit shorthand object properties - i.e.:
@@ -1019,6 +1026,8 @@ as "output options".
1019
1026
 
1020
1027
  - `shebang` (default `true`) -- preserve shebang `#!` in preamble (bash scripts)
1021
1028
 
1029
+ - `spidermonkey` (default `false`) -- produce a Spidermonkey (Mozilla) AST
1030
+
1022
1031
  - `webkit` (default `false`) -- enable workarounds for WebKit bugs.
1023
1032
  PhantomJS users should set this option to `true`.
1024
1033
 
@@ -1190,6 +1199,9 @@ JavaScript, but JS code described in SpiderMonkey AST in JSON. Therefore we
1190
1199
  don't use our own parser in this case, but just transform that AST into our
1191
1200
  internal AST.
1192
1201
 
1202
+ `spidermonkey` is also available in `minify` as `parse` and `format` options to
1203
+ accept and/or produce a spidermonkey AST.
1204
+
1193
1205
  ### Use Acorn for parsing
1194
1206
 
1195
1207
  More for fun, I added the `-p acorn` option which will use Acorn to do all