terser 5.6.0-beta → 5.7.1
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 +35 -0
- package/README.md +25 -19
- package/dist/bundle.min.js +250 -169
- package/lib/ast.js +15 -4
- package/lib/cli.js +0 -2
- package/lib/compress/index.js +102 -64
- package/lib/equivalent-to.js +5 -0
- package/lib/minify.js +26 -9
- package/lib/output.js +8 -1
- package/lib/parse.js +72 -80
- package/lib/scope.js +8 -3
- package/lib/size.js +9 -2
- package/lib/utils/index.js +6 -6
- package/package.json +4 -3
- package/tools/domprops.js +1 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,40 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.7.1
|
4
|
+
|
5
|
+
- Avoided collapsing assignments together if it would place a chain assignment on the left hand side, which is invalid syntax (`a?.b = c`)
|
6
|
+
- Removed undefined from object expansions (`{ ...void 0 }` -> `{}`)
|
7
|
+
- Fix crash when checking if something is nullish or undefined (#1009)
|
8
|
+
- Fixed comparison of private class properties (#1015)
|
9
|
+
- Minor performance improvements (#993)
|
10
|
+
- Fixed scope of function defs in strict mode (they are block scoped)
|
11
|
+
|
12
|
+
## v5.7.0
|
13
|
+
|
14
|
+
- Several compile-time evaluation and inlining fixes
|
15
|
+
- Allow `reduce_funcs` to be disabled again.
|
16
|
+
- Add `spidermonkey` options to parse and format (#974)
|
17
|
+
- Accept `{get = "default val"}` and `{set = "default val"}` in destructuring arguments.
|
18
|
+
- Change package.json export map to help require.resolve (#971)
|
19
|
+
- Improve docs
|
20
|
+
- Fix `export default` of an anonymous class with `extends`
|
21
|
+
|
22
|
+
## v5.6.1
|
23
|
+
|
24
|
+
- Mark assignments to the `.prototype` of a class as pure
|
25
|
+
- Parenthesize `await` on the left of `**` (while accepting legacy non-parenthesised input)
|
26
|
+
- Avoided outputting NUL bytes in optimized RegExps, to stop the output from breaking other tools
|
27
|
+
- Added `exports` to domprops (#939)
|
28
|
+
- Fixed a crash when spreading `...this`
|
29
|
+
- Fixed the computed size of arrow functions, which improves their inlining
|
30
|
+
|
31
|
+
## v5.6.0
|
32
|
+
|
33
|
+
- Added top-level await
|
34
|
+
- Beautify option has been removed in #895
|
35
|
+
- Private properties, getters and setters have been added in #913 and some more commits
|
36
|
+
- Docs improvements: #896, #903, #916
|
37
|
+
|
3
38
|
## v5.5.1
|
4
39
|
|
5
40
|
- 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://
|
25
|
-
[travis-url]: https://travis-ci.
|
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.
|
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; }";
|
@@ -608,7 +608,7 @@ try {
|
|
608
608
|
module: false,
|
609
609
|
nameCache: null, // or specify a name cache object
|
610
610
|
safari10: false,
|
611
|
-
toplevel: false
|
611
|
+
toplevel: false
|
612
612
|
}
|
613
613
|
```
|
614
614
|
|
@@ -669,6 +669,8 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
669
669
|
|
670
670
|
- `shebang` (default `true`) -- support `#!command` as the first line
|
671
671
|
|
672
|
+
- `spidermonkey` (default `false`) -- accept a Spidermonkey (Mozilla) AST
|
673
|
+
|
672
674
|
## Compress options
|
673
675
|
|
674
676
|
- `defaults` (default: `true`) -- Pass `false` to disable most default
|
@@ -795,11 +797,13 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
795
797
|
Specify `"strict"` to treat `foo.bar` as side-effect-free only when
|
796
798
|
`foo` is certain to not throw, i.e. not `null` or `undefined`.
|
797
799
|
|
798
|
-
- `reduce_funcs` (legacy option, safely ignored for backwards compatibility).
|
799
|
-
|
800
800
|
- `reduce_vars` (default: `true`) -- Improve optimization on variables assigned with and
|
801
801
|
used as constant values.
|
802
802
|
|
803
|
+
- `reduce_funcs` (default: `true`) -- Inline single-use functions when
|
804
|
+
possible. Depends on `reduce_vars` being enabled. Disabling this option
|
805
|
+
sometimes improves performance of the output code.
|
806
|
+
|
803
807
|
- `sequences` (default: `true`) -- join consecutive simple statements using the
|
804
808
|
comma operator. May be set to a positive integer to specify the maximum number
|
805
809
|
of consecutive comma sequences that will be generated. If this option is set to
|
@@ -848,7 +852,7 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
848
852
|
- `unsafe_math` (default: `false`) -- optimize numerical expressions like
|
849
853
|
`2 * x * 3` into `6 * x`, which may give imprecise floating point results.
|
850
854
|
|
851
|
-
- `unsafe_symbols` (default: `false`) -- removes keys from native Symbol
|
855
|
+
- `unsafe_symbols` (default: `false`) -- removes keys from native Symbol
|
852
856
|
declarations, e.g `Symbol("kDog")` becomes `Symbol()`.
|
853
857
|
|
854
858
|
- `unsafe_methods` (default: false) -- Converts `{ m: function(){} }` to
|
@@ -929,11 +933,10 @@ await minify(code, { mangle: { toplevel: true } }).code;
|
|
929
933
|
- `debug` (default: `false`) — Mangle names with the original name still present.
|
930
934
|
Pass an empty string `""` to enable, or a non-empty string to set the debug suffix.
|
931
935
|
|
932
|
-
- `keep_quoted` (default: `false`) —
|
933
|
-
- `
|
934
|
-
|
935
|
-
- `
|
936
|
-
explicitly reserved.
|
936
|
+
- `keep_quoted` (default: `false`) — How quoting properties (`{"prop": ...}` and `obj["prop"]`) controls what gets mangled.
|
937
|
+
- `"strict"` (recommended) -- `obj.prop` is mangled.
|
938
|
+
- `false` -- `obj["prop"]` is mangled.
|
939
|
+
- `true` -- `obj.prop` is mangled unless there is `obj["prop"]` elsewhere in the code.
|
937
940
|
|
938
941
|
- `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
942
|
|
@@ -954,19 +957,17 @@ as "output options".
|
|
954
957
|
- `ascii_only` (default `false`) -- escape Unicode characters in strings and
|
955
958
|
regexps (affects directives with non-ascii characters becoming invalid)
|
956
959
|
|
957
|
-
- `beautify` (default `false`) -- whether to
|
958
|
-
|
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.
|
960
|
+
- `beautify` (default `false`) -- (DEPRECATED) whether to beautify the output.
|
961
|
+
When using the legacy `-b` CLI flag, this is set to true by default.
|
961
962
|
|
962
963
|
- `braces` (default `false`) -- always insert braces in `if`, `for`,
|
963
964
|
`do`, `while` or `with` statements, even if their body is a single
|
964
965
|
statement.
|
965
966
|
|
966
967
|
- `comments` (default `"some"`) -- by default it keeps JSDoc-style comments
|
967
|
-
that contain "@license"
|
968
|
-
comments, `false` to omit comments in the output,
|
969
|
-
(e.g. `/^!/`) or a function.
|
968
|
+
that contain "@license", "@preserve" or start with `!`, pass `true` or
|
969
|
+
`"all"` to preserve all comments, `false` to omit comments in the output,
|
970
|
+
a regular expression string (e.g. `/^!/`) or a function.
|
970
971
|
|
971
972
|
- `ecma` (default `5`) -- set desired EcmaScript standard version for output.
|
972
973
|
Set `ecma` to `2015` or greater to emit shorthand object properties - i.e.:
|
@@ -1019,6 +1020,8 @@ as "output options".
|
|
1019
1020
|
|
1020
1021
|
- `shebang` (default `true`) -- preserve shebang `#!` in preamble (bash scripts)
|
1021
1022
|
|
1023
|
+
- `spidermonkey` (default `false`) -- produce a Spidermonkey (Mozilla) AST
|
1024
|
+
|
1022
1025
|
- `webkit` (default `false`) -- enable workarounds for WebKit bugs.
|
1023
1026
|
PhantomJS users should set this option to `true`.
|
1024
1027
|
|
@@ -1190,6 +1193,9 @@ JavaScript, but JS code described in SpiderMonkey AST in JSON. Therefore we
|
|
1190
1193
|
don't use our own parser in this case, but just transform that AST into our
|
1191
1194
|
internal AST.
|
1192
1195
|
|
1196
|
+
`spidermonkey` is also available in `minify` as `parse` and `format` options to
|
1197
|
+
accept and/or produce a spidermonkey AST.
|
1198
|
+
|
1193
1199
|
### Use Acorn for parsing
|
1194
1200
|
|
1195
1201
|
More for fun, I added the `-p acorn` option which will use Acorn to do all
|