terser 5.9.0 → 5.14.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 +63 -0
- package/README.md +30 -8
- package/dist/bundle.min.js +5407 -3433
- package/lib/ast.js +1685 -348
- package/lib/cli.js +13 -9
- package/lib/compress/common.js +48 -0
- package/lib/compress/evaluate.js +18 -17
- package/lib/compress/index.js +57 -551
- package/lib/compress/inline.js +641 -0
- package/lib/compress/native-objects.js +1 -0
- package/lib/compress/tighten-body.js +1 -1
- package/lib/equivalent-to.js +81 -107
- package/lib/minify.js +96 -15
- package/lib/mozilla-ast.js +522 -87
- package/lib/output.js +94 -24
- package/lib/parse.js +91 -72
- package/lib/propmangle.js +1 -1
- package/lib/scope.js +27 -4
- package/lib/size.js +6 -8
- package/lib/sourcemap.js +60 -26
- package/lib/utils/index.js +9 -1
- package/package.json +9 -5
- package/tools/domprops.js +12 -0
- package/tools/terser.d.ts +6 -3
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,61 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.14.2
|
4
|
+
|
5
|
+
- Security fix for RegExps that should not be evaluated (regexp DDOS)
|
6
|
+
- Source maps improvements (#1211)
|
7
|
+
- Performance improvements in long property access evaluation (#1213)
|
8
|
+
|
9
|
+
## v5.14.1
|
10
|
+
- keep_numbers option added to TypeScript defs (#1208)
|
11
|
+
- Fixed parsing of nested template strings (#1204)
|
12
|
+
|
13
|
+
## v5.14.0
|
14
|
+
- Switched to @jridgewell/source-map for sourcemap generation (#1190, #1181)
|
15
|
+
- Fixed source maps with non-terminated segments (#1106)
|
16
|
+
- Enabled typescript types to be imported from the package (#1194)
|
17
|
+
- Extra DOM props have been added (#1191)
|
18
|
+
- Delete the AST while generating code, as a means to save RAM
|
19
|
+
|
20
|
+
## v5.13.1
|
21
|
+
- Removed self-assignments (`varname=varname`) (closes #1081)
|
22
|
+
- Separated inlining code (for inlining things into references, or removing IIFEs)
|
23
|
+
- Allow multiple identifiers with the same name in `var` destructuring (eg `var { a, a } = x`) (#1176)
|
24
|
+
|
25
|
+
## v5.13.0
|
26
|
+
|
27
|
+
- All calls to eval() were removed (#1171, #1184)
|
28
|
+
- `source-map` was updated to 0.8.0-beta.0 (#1164)
|
29
|
+
- NavigatorUAData was added to domprops to avoid property mangling (#1166)
|
30
|
+
|
31
|
+
## v5.12.1
|
32
|
+
|
33
|
+
- Fixed an issue with function definitions inside blocks (#1155)
|
34
|
+
- Fixed parens of `new` in some situations (closes #1159)
|
35
|
+
|
36
|
+
## v5.12.0
|
37
|
+
|
38
|
+
- `TERSER_DEBUG_DIR` environment variable
|
39
|
+
- @copyright comments are now preserved with the comments="some" option (#1153)
|
40
|
+
|
41
|
+
## v5.11.0
|
42
|
+
|
43
|
+
- Unicode code point escapes (`\u{abcde}`) are not emitted inside RegExp literals anymore (#1147)
|
44
|
+
- acorn is now a regular dependency
|
45
|
+
|
46
|
+
## v5.10.0
|
47
|
+
|
48
|
+
- Massive optimization to max_line_len (#1109)
|
49
|
+
- Basic support for import assertions
|
50
|
+
- Marked ES2022 Object.hasOwn as a pure function
|
51
|
+
- Fix `delete optional?.property`
|
52
|
+
- New CI/CD pipeline with github actions (#1057)
|
53
|
+
- Fix reordering of switch branches (#1092), (#1084)
|
54
|
+
- Fix error when creating a class property called `get`
|
55
|
+
- Acorn dependency is now an optional peerDependency
|
56
|
+
- Fix mangling collision with exported variables (#1072)
|
57
|
+
- Fix an issue with `return someVariable = (async () => { ... })()` (#1073)
|
58
|
+
|
3
59
|
## v5.9.0
|
4
60
|
|
5
61
|
- Collapsing switch cases with the same bodies (even if they're not next to each other) (#1070).
|
@@ -156,6 +212,13 @@ Hotfix release, fixes package.json "engines" syntax
|
|
156
212
|
- Module is now distributed as a dual package - You can `import` and `require()` too.
|
157
213
|
- Inline improvements were made
|
158
214
|
|
215
|
+
|
216
|
+
-----
|
217
|
+
|
218
|
+
## v4.8.1 (backport)
|
219
|
+
|
220
|
+
- Security fix for RegExps that should not be evaluated (regexp DDOS)
|
221
|
+
|
159
222
|
## v4.8.0
|
160
223
|
|
161
224
|
- Support for numeric separators (`million = 1_000_000`) was added.
|
package/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Travis Build][travis-image]][travis-url]
|
6
6
|
[![Opencollective financial contributors][opencollective-contributors]][opencollective-url]
|
7
7
|
|
8
|
-
A JavaScript
|
8
|
+
A JavaScript mangler/compressor toolkit for ES6+.
|
9
9
|
|
10
10
|
*note*: You can support this project on patreon: <a target="_blank" rel="nofollow" href="https://www.patreon.com/fabiosantoscode"><img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" alt="patron" width="100px" height="auto"></a>. Check out [PATRONS.md](https://github.com/terser/terser/blob/master/PATRONS.md) for our first-tier patrons.
|
11
11
|
|
@@ -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
|
@@ -121,8 +127,8 @@ a double dash to prevent input files being used as option arguments:
|
|
121
127
|
as JSON to STDOUT respectively.
|
122
128
|
--comments [filter] Preserve copyright comments in the output. By
|
123
129
|
default this works like Google Closure, keeping
|
124
|
-
JSDoc-style comments that contain "@license"
|
125
|
-
"
|
130
|
+
JSDoc-style comments that contain e.g. "@license",
|
131
|
+
or start with "!". You can optionally pass one of the
|
126
132
|
following arguments to this flag:
|
127
133
|
- "all" to keep all comments
|
128
134
|
- `false` to omit comments in the output
|
@@ -983,8 +989,8 @@ as "output options".
|
|
983
989
|
statement.
|
984
990
|
|
985
991
|
- `comments` (default `"some"`) -- by default it keeps JSDoc-style comments
|
986
|
-
that contain "@license", "@preserve" or start with `!`, pass `true`
|
987
|
-
`"all"` to preserve all comments, `false` to omit comments in the output,
|
992
|
+
that contain "@license", "@copyright", "@preserve" or start with `!`, pass `true`
|
993
|
+
or `"all"` to preserve all comments, `false` to omit comments in the output,
|
988
994
|
a regular expression string (e.g. `/^!/`) or a function.
|
989
995
|
|
990
996
|
- `ecma` (default `5`) -- set desired EcmaScript standard version for output.
|
@@ -1056,9 +1062,9 @@ as "output options".
|
|
1056
1062
|
### Keeping copyright notices or other comments
|
1057
1063
|
|
1058
1064
|
You can pass `--comments` to retain certain comments in the output. By
|
1059
|
-
default it will keep JSDoc-style comments that
|
1060
|
-
"@license" or "@cc_on" (conditional compilation for IE).
|
1061
|
-
`--comments all` to keep all the comments, or a valid JavaScript regexp to
|
1065
|
+
default it will keep comments starting with "!" and JSDoc-style comments that
|
1066
|
+
contain "@preserve", "@copyright", "@license" or "@cc_on" (conditional compilation for IE).
|
1067
|
+
You can pass `--comments all` to keep all the comments, or a valid JavaScript regexp to
|
1062
1068
|
keep only comments that match this regexp. For example `--comments /^!/`
|
1063
1069
|
will keep comments like `/*! Copyright Notice */`.
|
1064
1070
|
|
@@ -1312,6 +1318,22 @@ $ yarn
|
|
1312
1318
|
|
1313
1319
|
In the terser CLI we use [source-map-support](https://npmjs.com/source-map-support) to produce good error stacks. In your own app, you're expected to enable source-map-support (read their docs) to have nice stack traces that will help you write good issues.
|
1314
1320
|
|
1321
|
+
## Obtaining the source code given to Terser
|
1322
|
+
|
1323
|
+
Because users often don't control the call to `await minify()` or its arguments, Terser provides a `TERSER_DEBUG_DIR` environment variable to make terser output some debug logs. If you're using a bundler or a project that includes a bundler and are not sure what went wrong with your code, pass that variable like so:
|
1324
|
+
|
1325
|
+
```
|
1326
|
+
$ TERSER_DEBUG_DIR=/path/to/logs command-that-uses-terser
|
1327
|
+
$ ls /path/to/logs
|
1328
|
+
terser-debug-123456.log
|
1329
|
+
```
|
1330
|
+
|
1331
|
+
If you're not sure how to set an environment variable on your shell (the above example works in bash), you can try using cross-env:
|
1332
|
+
|
1333
|
+
```
|
1334
|
+
> npx cross-env TERSER_DEBUG_DIR=/path/to/logs command-that-uses-terser
|
1335
|
+
```
|
1336
|
+
|
1315
1337
|
# README.md Patrons:
|
1316
1338
|
|
1317
1339
|
*note*: You can support this project on patreon: <a target="_blank" rel="nofollow" href="https://www.patreon.com/fabiosantoscode"><img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" alt="patron" width="100px" height="auto"></a>. Check out [PATRONS.md](https://github.com/terser/terser/blob/master/PATRONS.md) for our first-tier patrons.
|