terser 4.4.1 → 4.5.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.
Potentially problematic release.
This version of terser might be problematic. Click here for more details.
- package/CHANGELOG.md +20 -0
- package/PATRONS.md +2 -0
- package/README.md +18 -11
- package/bin/terser +6 -2
- package/dist/bundle.min.js +1 -1
- package/dist/bundle.min.js.map +1 -1
- package/package.json +1 -1
- package/tools/postinstall.js +7 -0
- package/tools/terser.d.ts +4 -1
package/CHANGELOG.md
CHANGED
@@ -1,8 +1,28 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v4.5.0
|
4
|
+
|
5
|
+
- Inlining has been improved
|
6
|
+
- An issue where keep_fnames combined with functions declared through variables was causing name shadowing has been fixed
|
7
|
+
- You can now set the ES version through their year
|
8
|
+
- The output option `keep_numbers` has been added, which prevents Terser from turning `1000` into `1e3` and such
|
9
|
+
- Internal small optimisations and refactors
|
10
|
+
|
11
|
+
## v4.4.3
|
12
|
+
|
13
|
+
- Number and BigInt parsing has been fixed
|
14
|
+
- `/*#__INLINE__*/` annotation fixed for arrow functions with non-block bodies.
|
15
|
+
- Functional tests have been added, using [this repository](https://github.com/terser/terser-functional-tests).
|
16
|
+
- A memory leak, where the entire AST lives on after compression, has been plugged.
|
17
|
+
|
18
|
+
## v4.4.2
|
19
|
+
|
20
|
+
- Fixed a problem with inlining identity functions
|
3
21
|
|
4
22
|
## v4.4.1
|
5
23
|
|
24
|
+
*note:* This introduced a feature, therefore it should have been a minor release.
|
25
|
+
|
6
26
|
- Fixed a crash when `unsafe` was enabled.
|
7
27
|
- An issue has been fixed where `let` statements might be collapsed out of their scope.
|
8
28
|
- Some error messages have been improved by adding quotes around variable names.
|
package/PATRONS.md
CHANGED
@@ -4,6 +4,7 @@ These are the first-tier patrons from [Patreon](https://www.patreon.com/fabiosan
|
|
4
4
|
|
5
5
|
* 38elements
|
6
6
|
* Alan Orozco
|
7
|
+
* Aria Buckles
|
7
8
|
* CKEditor
|
8
9
|
* Mariusz Nowak
|
9
10
|
* Nakshatra Mukhopadhyay
|
@@ -11,3 +12,4 @@ These are the first-tier patrons from [Patreon](https://www.patreon.com/fabiosan
|
|
11
12
|
* Piotrek Koszuliński
|
12
13
|
* Serhiy Shyyko
|
13
14
|
* Viktor Hubert
|
15
|
+
* 龙腾道
|
package/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
[![NPM Version][npm-image]][npm-url]
|
4
4
|
[![NPM Downloads][downloads-image]][downloads-url]
|
5
|
-
[![
|
5
|
+
[![Travis Build][travis-image]][travis-url]
|
6
|
+
[![Opencollective financial contributors][opencollective-contributors]][opencollective-url]
|
6
7
|
|
7
8
|
A JavaScript parser and mangler/compressor toolkit for ES6+.
|
8
9
|
|
@@ -22,6 +23,8 @@ Find the changelog in [CHANGELOG.md](https://github.com/terser/terser/blob/maste
|
|
22
23
|
[downloads-url]: https://npmjs.org/package/terser
|
23
24
|
[travis-image]: https://img.shields.io/travis/terser/terser/master.svg
|
24
25
|
[travis-url]: https://travis-ci.org/terser/terser
|
26
|
+
[opencollective-contributors]: https://opencollective.com/terser/tiers/badge.svg
|
27
|
+
[opencollective-url]: https://opencollective.com/terser
|
25
28
|
|
26
29
|
Why choose terser?
|
27
30
|
------------------
|
@@ -531,7 +534,7 @@ if (result.error) throw result.error;
|
|
531
534
|
|
532
535
|
## Minify options
|
533
536
|
|
534
|
-
- `ecma` (default `undefined`) - pass `5`, `
|
537
|
+
- `ecma` (default `undefined`) - pass `5`, `2015`, `2016` or `2017` to override `parse`,
|
535
538
|
`compress` and `output`'s `ecma` options.
|
536
539
|
|
537
540
|
- `warnings` (default `false`) — pass `true` to return compressor warnings
|
@@ -608,7 +611,7 @@ if (result.error) throw result.error;
|
|
608
611
|
sourceMap: {
|
609
612
|
// source map options
|
610
613
|
},
|
611
|
-
ecma: 5, // specify one of: 5,
|
614
|
+
ecma: 5, // specify one of: 5, 2015, 2016, 2017 or 2018
|
612
615
|
keep_classnames: false,
|
613
616
|
keep_fnames: false,
|
614
617
|
ie8: false,
|
@@ -673,9 +676,9 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
673
676
|
|
674
677
|
- `bare_returns` (default `false`) -- support top level `return` statements
|
675
678
|
|
676
|
-
- `ecma` (default: `
|
679
|
+
- `ecma` (default: `2017`) -- specify one of `5`, `2015`, `2016` or `2017`. Note: this setting
|
677
680
|
is not presently enforced except for ES8 optional trailing commas in function
|
678
|
-
parameter lists and calls with `ecma` `
|
681
|
+
parameter lists and calls with `ecma` `2017`.
|
679
682
|
|
680
683
|
- `html5_comments` (default `true`)
|
681
684
|
|
@@ -683,9 +686,10 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
683
686
|
|
684
687
|
## Compress options
|
685
688
|
|
686
|
-
- `arrows` (default: `true`) --
|
687
|
-
|
688
|
-
|
689
|
+
- `arrows` (default: `true`) -- Class and object literal methods are converted
|
690
|
+
will also be converted to arrow expressions if the resultant code is shorter:
|
691
|
+
`m(){return x}` becomes `m:()=>x`. To do this to regular ES5 functions which
|
692
|
+
don't use `this` or `arguments`, see `unsafe_arrows`.
|
689
693
|
|
690
694
|
- `arguments` (default: `false`) -- replace `arguments[index]` with function
|
691
695
|
parameter name whenever possible.
|
@@ -724,7 +728,7 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
724
728
|
|
725
729
|
- `drop_debugger` (default: `true`) -- remove `debugger;` statements
|
726
730
|
|
727
|
-
- `ecma` (default: `5`) -- Pass `
|
731
|
+
- `ecma` (default: `5`) -- Pass `2015` or greater to enable `compress` options that
|
728
732
|
will transform ES5 code into smaller ES6+ equivalent forms.
|
729
733
|
|
730
734
|
- `evaluate` (default: `true`) -- attempt to evaluate constant expressions
|
@@ -846,7 +850,7 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
|
846
850
|
expressions to arrow functions if the function body does not reference `this`.
|
847
851
|
Note: it is not always safe to perform this conversion if code relies on the
|
848
852
|
the function having a `prototype`, which arrow functions lack.
|
849
|
-
This transform requires that the `ecma` compress option is set to `
|
853
|
+
This transform requires that the `ecma` compress option is set to `2015` or greater.
|
850
854
|
|
851
855
|
- `unsafe_comps` (default: `false`) -- Reverse `<` and `<=` to `>` and `>=` to
|
852
856
|
allow improved compression. This might be unsafe when an at least one of two
|
@@ -981,7 +985,7 @@ can pass additional arguments that control the code output:
|
|
981
985
|
comments, `false` to omit comments in the output, a regular expression string
|
982
986
|
(e.g. `/^!/`) or a function.
|
983
987
|
|
984
|
-
- `ecma` (default `5`) -- set output printing mode. Set `ecma` to `
|
988
|
+
- `ecma` (default `5`) -- set output printing mode. Set `ecma` to `2015` or
|
985
989
|
greater to emit shorthand object properties - i.e.: `{a}` instead of `{a: a}`.
|
986
990
|
The `ecma` option will only change the output in direct control of the
|
987
991
|
beautifier. Non-compatible features in the abstract syntax tree will still
|
@@ -995,6 +999,9 @@ can pass additional arguments that control the code output:
|
|
995
999
|
- `inline_script` (default `true`) -- escape HTML comments and the slash in
|
996
1000
|
occurrences of `</script>` in strings
|
997
1001
|
|
1002
|
+
- `keep_numbers` (default `false`) -- keep number literals as it was in original code
|
1003
|
+
(disables optimizations like converting `1000000` into `1e6`)
|
1004
|
+
|
998
1005
|
- `keep_quoted_props` (default `false`) -- when turned on, prevents stripping
|
999
1006
|
quotes from property names in object literals.
|
1000
1007
|
|
package/bin/terser
CHANGED
@@ -45,7 +45,7 @@ program.option("-o, --output <file>", "Output file (default STDOUT).");
|
|
45
45
|
program.option("--comments [filter]", "Preserve copyright comments in the output.");
|
46
46
|
program.option("--config-file <file>", "Read minify() options from JSON file.");
|
47
47
|
program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
|
48
|
-
program.option("--ecma <version>", "Specify ECMAScript release: 5,
|
48
|
+
program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
|
49
49
|
program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
|
50
50
|
program.option("--ie8", "Support non-standard Internet Explorer 8.");
|
51
51
|
program.option("--keep-classnames", "Do not mangle/drop class names.");
|
@@ -85,7 +85,11 @@ if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
|
|
85
85
|
});
|
86
86
|
if ("ecma" in program) {
|
87
87
|
if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
|
88
|
-
|
88
|
+
const ecma = program.ecma | 0;
|
89
|
+
if (ecma > 5 && ecma < 2015)
|
90
|
+
options.ecma = ecma + 2009;
|
91
|
+
else
|
92
|
+
options.ecma = ecma;
|
89
93
|
}
|
90
94
|
if (program.beautify) {
|
91
95
|
options.output = typeof program.beautify == "object" ? program.beautify : {};
|