terser 5.7.2 → 5.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.
- package/CHANGELOG.md +36 -0
- package/README.md +21 -2
- package/dist/bundle.min.js +705 -213
- package/lib/ast.js +6 -4
- package/lib/compress/drop-side-effect-free.js +9 -12
- package/lib/compress/evaluate.js +15 -12
- package/lib/compress/index.js +368 -66
- package/lib/compress/inference.js +27 -13
- package/lib/compress/native-objects.js +1 -0
- package/lib/compress/tighten-body.js +29 -7
- package/lib/minify.js +3 -1
- package/lib/mozilla-ast.js +48 -6
- package/lib/output.js +81 -26
- package/lib/parse.js +24 -8
- package/lib/propmangle.js +57 -34
- package/lib/scope.js +42 -21
- package/lib/transform.js +2 -2
- package/package.json +9 -9
- package/tools/terser.d.ts +36 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,41 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.11.0
|
4
|
+
|
5
|
+
- Unicode code point escapes (`\u{abcde}`) are not emitted inside RegExp literals anymore (#1147)
|
6
|
+
- acorn is now a regular dependency
|
7
|
+
|
8
|
+
## v5.10.0
|
9
|
+
|
10
|
+
- Massive optimization to max_line_len (#1109)
|
11
|
+
- Basic support for import assertions
|
12
|
+
- Marked ES2022 Object.hasOwn as a pure function
|
13
|
+
- Fix `delete optional?.property`
|
14
|
+
- New CI/CD pipeline with github actions (#1057)
|
15
|
+
- Fix reordering of switch branches (#1092), (#1084)
|
16
|
+
- Fix error when creating a class property called `get`
|
17
|
+
- Acorn dependency is now an optional peerDependency
|
18
|
+
- Fix mangling collision with exported variables (#1072)
|
19
|
+
- Fix an issue with `return someVariable = (async () => { ... })()` (#1073)
|
20
|
+
|
21
|
+
## v5.9.0
|
22
|
+
|
23
|
+
- Collapsing switch cases with the same bodies (even if they're not next to each other) (#1070).
|
24
|
+
- Fix evaluation of optional chain expressions (#1062)
|
25
|
+
- Fix mangling collision in ESM exports (#1063)
|
26
|
+
- Fix issue with mutating function objects after a second pass (#1047)
|
27
|
+
- Fix for inlining object spread `{ ...obj }` (#1071)
|
28
|
+
- Typescript typings fix (#1069)
|
29
|
+
|
30
|
+
## v5.8.0
|
31
|
+
|
32
|
+
- Fixed shadowing variables while moving code in some cases (#1065)
|
33
|
+
- Stop mangling computed & quoted properties when keep_quoted is enabled.
|
34
|
+
- Fix for mangling private getter/setter and .#private access (#1060, #1068)
|
35
|
+
- Array.from has a new optimization when the unsafe option is set (#737)
|
36
|
+
- Mangle/propmangle let you generate your own identifiers through the nth_identifier option (#1061)
|
37
|
+
- More optimizations to switch statements (#1044)
|
38
|
+
|
3
39
|
## v5.7.2
|
4
40
|
|
5
41
|
- Fixed issues with compressing functions defined in `global_defs` option (#1036)
|
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://travis-ci.com/terser/terser.svg?branch=master
|
25
|
-
[travis-url]: https://travis-ci.com/terser/terser
|
24
|
+
[travis-image]: https://app.travis-ci.com/terser/terser.svg?branch=master
|
25
|
+
[travis-url]: https://app.travis-ci.com/github/terser/terser
|
26
26
|
[opencollective-contributors]: https://opencollective.com/terser/tiers/badge.svg
|
27
27
|
[opencollective-url]: https://opencollective.com/terser
|
28
28
|
|
@@ -60,6 +60,12 @@ in sequence and apply any compression options. The files are parsed in the
|
|
60
60
|
same global scope, that is, a reference from a file to some
|
61
61
|
variable/function declared in another file will be matched properly.
|
62
62
|
|
63
|
+
Command line arguments that take options (like --parse, --compress, --mangle and
|
64
|
+
--format) can take in a comma-separated list of default option overrides. For
|
65
|
+
instance:
|
66
|
+
|
67
|
+
terser input.js --compress ecma=2015,computed_props=false
|
68
|
+
|
63
69
|
If no input file is specified, Terser will read from STDIN.
|
64
70
|
|
65
71
|
If you wish to pass your options before the input files, separate the two with
|
@@ -898,6 +904,12 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
898
904
|
- `module` (default `false`) -- Pass `true` an ES6 modules, where the toplevel
|
899
905
|
scope is not the global scope. Implies `toplevel`.
|
900
906
|
|
907
|
+
- `nth_identifier` (default: an internal mangler that weights based on character
|
908
|
+
frequency analysis) -- Pass an object with a `get(n)` function that converts an
|
909
|
+
ordinal into the nth most favored (usually shortest) identifier.
|
910
|
+
Optionally also provide `reset()`, `sort()`, and `consider(chars, delta)` to
|
911
|
+
use character frequency analysis of the source code.
|
912
|
+
|
901
913
|
- `reserved` (default `[]`) -- Pass an array of identifiers that should be
|
902
914
|
excluded from mangling. Example: `["foo", "bar"]`.
|
903
915
|
|
@@ -944,6 +956,12 @@ await minify(code, { mangle: { toplevel: true } }).code;
|
|
944
956
|
- `false` -- `obj["prop"]` is mangled.
|
945
957
|
- `true` -- `obj.prop` is mangled unless there is `obj["prop"]` elsewhere in the code.
|
946
958
|
|
959
|
+
- `nth_identifer` (default: an internal mangler that weights based on character
|
960
|
+
frequency analysis) -- Pass an object with a `get(n)` function that converts an
|
961
|
+
ordinal into the nth most favored (usually shortest) identifier.
|
962
|
+
Optionally also provide `reset()`, `sort()`, and `consider(chars, delta)` to
|
963
|
+
use character frequency analysis of the source code.
|
964
|
+
|
947
965
|
- `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.
|
948
966
|
|
949
967
|
- `reserved` (default: `[]`) — Do not mangle property names listed in the
|
@@ -1078,6 +1096,7 @@ You might want to try it on your own code; it should reduce the minified size.
|
|
1078
1096
|
Some examples of the optimizations made when this option is enabled:
|
1079
1097
|
|
1080
1098
|
- `new Array(1, 2, 3)` or `Array(1, 2, 3)` → `[ 1, 2, 3 ]`
|
1099
|
+
- `Array.from([1, 2, 3])` → `[1, 2, 3]`
|
1081
1100
|
- `new Object()` → `{}`
|
1082
1101
|
- `String(exp)` or `exp.toString()` → `"" + exp`
|
1083
1102
|
- `new Object/RegExp/Function/Error/Array (...)` → we discard the `new`
|