terser 5.7.2 → 5.8.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 +9 -0
- package/README.md +15 -2
- package/bin/terser.mjs +21 -0
- package/dist/bundle.min.js +422 -110
- package/lib/ast.js +1 -1
- package/lib/compress/index.js +293 -44
- package/lib/compress/tighten-body.js +29 -7
- package/lib/minify.js +2 -2
- package/lib/output.js +9 -4
- package/lib/propmangle.js +54 -31
- package/lib/scope.js +37 -17
- 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,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.8.0
|
4
|
+
|
5
|
+
- Fixed shadowing variables while moving code in some cases (#1065)
|
6
|
+
- Stop mangling computed & quoted properties when keep_quoted is enabled.
|
7
|
+
- Fix for mangling private getter/setter and .#private access (#1060, #1068)
|
8
|
+
- Array.from has a new optimization when the unsafe option is set (#737)
|
9
|
+
- Mangle/propmangle let you generate your own identifiers through the nth_identifier option (#1061)
|
10
|
+
- More optimizations to switch statements (#1044)
|
11
|
+
|
3
12
|
## v5.7.2
|
4
13
|
|
5
14
|
- 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
|
|
@@ -898,6 +898,12 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
898
898
|
- `module` (default `false`) -- Pass `true` an ES6 modules, where the toplevel
|
899
899
|
scope is not the global scope. Implies `toplevel`.
|
900
900
|
|
901
|
+
- `nth_identifier` (default: an internal mangler that weights based on character
|
902
|
+
frequency analysis) -- Pass an object with a `get(n)` function that converts an
|
903
|
+
ordinal into the nth most favored (usually shortest) identifier.
|
904
|
+
Optionally also provide `reset()`, `sort()`, and `consider(chars, delta)` to
|
905
|
+
use character frequency analysis of the source code.
|
906
|
+
|
901
907
|
- `reserved` (default `[]`) -- Pass an array of identifiers that should be
|
902
908
|
excluded from mangling. Example: `["foo", "bar"]`.
|
903
909
|
|
@@ -944,6 +950,12 @@ await minify(code, { mangle: { toplevel: true } }).code;
|
|
944
950
|
- `false` -- `obj["prop"]` is mangled.
|
945
951
|
- `true` -- `obj.prop` is mangled unless there is `obj["prop"]` elsewhere in the code.
|
946
952
|
|
953
|
+
- `nth_identifer` (default: an internal mangler that weights based on character
|
954
|
+
frequency analysis) -- Pass an object with a `get(n)` function that converts an
|
955
|
+
ordinal into the nth most favored (usually shortest) identifier.
|
956
|
+
Optionally also provide `reset()`, `sort()`, and `consider(chars, delta)` to
|
957
|
+
use character frequency analysis of the source code.
|
958
|
+
|
947
959
|
- `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
960
|
|
949
961
|
- `reserved` (default: `[]`) — Do not mangle property names listed in the
|
@@ -1078,6 +1090,7 @@ You might want to try it on your own code; it should reduce the minified size.
|
|
1078
1090
|
Some examples of the optimizations made when this option is enabled:
|
1079
1091
|
|
1080
1092
|
- `new Array(1, 2, 3)` or `Array(1, 2, 3)` → `[ 1, 2, 3 ]`
|
1093
|
+
- `Array.from([1, 2, 3])` → `[1, 2, 3]`
|
1081
1094
|
- `new Object()` → `{}`
|
1082
1095
|
- `String(exp)` or `exp.toString()` → `"" + exp`
|
1083
1096
|
- `new Object/RegExp/Function/Error/Array (...)` → we discard the `new`
|
package/bin/terser.mjs
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
"use strict";
|
4
|
+
|
5
|
+
import "../tools/exit.cjs";
|
6
|
+
|
7
|
+
import fs from "fs"
|
8
|
+
import path from "path"
|
9
|
+
import program from "commander"
|
10
|
+
|
11
|
+
import { run_cli } from "../lib/cli.js"
|
12
|
+
|
13
|
+
const packageJson = {
|
14
|
+
name: "terser",
|
15
|
+
version: "experimental module CLI"
|
16
|
+
}
|
17
|
+
|
18
|
+
run_cli({ program, packageJson, fs, path }).catch((error) => {
|
19
|
+
console.error(error);
|
20
|
+
process.exitCode = 1;
|
21
|
+
});
|