terser 3.14.0-beta → 3.16.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 ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## v3.16.1
4
+
5
+ - Fixed issue where Terser being imported with `import` would cause it not to work due to the `__esModule` property.
6
+
7
+ ## v3.16.0
8
+
9
+ - No longer leaves names like Array or Object or window as a SimpleStatement (statement which is just a single expression).
10
+ - Add support for sections sourcemaps (IndexedSourceMapConsumer)
11
+ - Drops node.js v4 and starts using commonJS
12
+ - Is now built with rollup
13
+
14
+ ## v3.15.0
15
+
16
+ - Inlined spread syntax (`[...[1, 2, 3], 4, 5] => [1, 2, 3, 4, 5]`) in arrays and objects.
17
+ - Fixed typo in compressor warning
18
+ - Fixed inline source map input bug
19
+ - Fixed parsing of template literals with unnecessary escapes (Like `\\a`)
package/PATRONS.md ADDED
@@ -0,0 +1,5 @@
1
+ * 38elements
2
+ * CKEditor
3
+ * Philippe Léger
4
+ * Piotrek Koszuliński
5
+ * Viktor Hubert
package/README.md CHANGED
@@ -3,13 +3,17 @@ terser
3
3
 
4
4
  ![Terser](https://raw.githubusercontent.com/terser-js/terser/master/logo.png)
5
5
 
6
- *note*: You can support this project on patreon: <a target="_blank" rel="nofollow" href="https://www.patreon.com/terser_jscomp_maintainer"><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 for our first-tier patrons.
7
- =======
8
- *Note:* Support this project with patreon by clicking [here](https://www.patreon.com/terser_jscomp_maintainer) and becoming a patron.
6
+ A JavaScript parser and mangler/compressor toolkit for ES6+.
7
+
8
+ *note*: You can support this project on patreon: <a target="_blank" rel="nofollow" href="https://www.patreon.com/terser_ecmacomp_maintainer"><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 for our first-tier patrons.
9
+
10
+ Terser recommends you use RollupJS to bundle your modules, as that produces smaller code overall.
11
+
12
+ *Beautification* has been undocumented and is *being removed* from terser, we recommend you use [prettier](https://npmjs.com/package/prettier).
9
13
 
10
14
  [![Build Status](https://travis-ci.org/terser-js/terser.svg?branch=master)](https://travis-ci.org/terser-js/terser) [![Coverage Status](https://coveralls.io/repos/github/terser-js/terser/badge.svg?branch=master)](https://coveralls.io/github/terser-js/terser?branch=master)
11
15
 
12
- A JavaScript parser, mangler/compressor and beautifier toolkit for ES6+.
16
+ Find the changelog in [CHANGELOG.md](https://github.com/terser-js/terser/blob/master/CHANGELOG.md)
13
17
 
14
18
 
15
19
  Why choose terser?
@@ -83,8 +87,6 @@ a double dash to prevent input files being used as option arguments:
83
87
  `keep_quoted` Only mangle unquoted properties.
84
88
  `regex` Only mangle matched property names.
85
89
  `reserved` List of names that should not be mangled.
86
- -b, --beautify [options] Beautify output/specify output options:
87
- `beautify` Enabled with `--beautify` by default.
88
90
  `preamble` Preamble to prepend to the output. You
89
91
  can use this to insert a comment, for
90
92
  example for licensing information.
@@ -237,7 +239,7 @@ to prevent the `require`, `exports` and `$` names from being changed.
237
239
 
238
240
  ### CLI mangling property names (`--mangle-props`)
239
241
 
240
- **Note:** THIS WILL PROBABLY BREAK YOUR CODE. Mangling property names
242
+ **Note:** THIS *MIGHT* BREAK YOUR CODE. Mangling property names
241
243
  is a separate step, different from variable name mangling. Pass
242
244
  `--mangle-props` to enable it. It will mangle all properties in the
243
245
  input code with the exception of built in DOM properties and properties
@@ -367,6 +369,11 @@ like this:
367
369
  ```javascript
368
370
  var Terser = require("terser");
369
371
  ```
372
+ Browser loading is also supported:
373
+ ```html
374
+ <script src="node_modules/source-map/dist/source-map.min.js"></script>
375
+ <script src="dist/bundle.min.js"></script>
376
+ ```
370
377
 
371
378
  There is a single high level function, **`minify(code, options)`**,
372
379
  which will perform all minification [phases](#minify-options) in a configurable
@@ -459,7 +466,6 @@ var options = {
459
466
  passes: 2
460
467
  },
461
468
  output: {
462
- beautify: false,
463
469
  preamble: "/* minified */"
464
470
  }
465
471
  };
@@ -917,18 +923,12 @@ Terser.minify(code, { mangle: { toplevel: true } }).code;
917
923
 
918
924
  ## Output options
919
925
 
920
- The code generator tries to output shortest code possible by default. In
921
- case you want beautified output, pass `--beautify` (`-b`). Optionally you
926
+ The code generator tries to output shortest code possible. Optionally you
922
927
  can pass additional arguments that control the code output:
923
928
 
924
929
  - `ascii_only` (default `false`) -- escape Unicode characters in strings and
925
930
  regexps (affects directives with non-ascii characters becoming invalid)
926
931
 
927
- - `beautify` (default `true`) -- whether to actually beautify the output.
928
- Passing `-b` will set this to true, but you might need to pass `-b` even
929
- when you want to generate minified code, in order to specify additional
930
- arguments, so you can use `-b beautify=false` to override it.
931
-
932
932
  - `braces` (default `false`) -- always insert braces in `if`, `for`,
933
933
  `do`, `while` or `with` statements, even if their body is a single
934
934
  statement.
@@ -939,8 +939,7 @@ can pass additional arguments that control the code output:
939
939
 
940
940
  - `ecma` (default `5`) -- set output printing mode. Set `ecma` to `6` or
941
941
  greater to emit shorthand object properties - i.e.: `{a}` instead of `{a: a}`.
942
- The `ecma` option will only change the output in direct control of the
943
- beautifier. Non-compatible features in the abstract syntax tree will still
942
+ Non-compatible features in the abstract syntax tree will still
944
943
  be output as is. For example: an `ecma` setting of `5` will **not** convert
945
944
  ES6+ code to ES5.
946
945
 
@@ -986,12 +985,6 @@ can pass additional arguments that control the code output:
986
985
  - `webkit` (default `false`) -- enable workarounds for WebKit bugs.
987
986
  PhantomJS users should set this option to `true`.
988
987
 
989
- - `width` (default `80`) -- only takes effect when beautification is on, this
990
- specifies an (orientative) line width that the beautifier will try to
991
- obey. It refers to the width of the line text (excluding indentation).
992
- It doesn't work very well currently, but it does make the code generated
993
- by Terser more readable.
994
-
995
988
  - `wrap_iife` (default `false`) -- pass `true` to wrap immediately invoked
996
989
  function expressions. See
997
990
  [#640](https://github.com/mishoo/UglifyJS2/issues/640) for more details.
@@ -1277,8 +1270,8 @@ In the terser CLI we use [source-map-support](https://npmjs.com/source-map-suppo
1277
1270
 
1278
1271
  # README.md Patrons:
1279
1272
 
1280
- *note*: You can support this project on patreon: <a target="_blank" rel="nofollow" href="https://www.patreon.com/terser_jscomp_maintainer"><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 for our first-tier patrons.
1281
-
1273
+ *note*: You can support this project on patreon: <a target="_blank" rel="nofollow" href="https://www.patreon.com/terser_ecmacomp_maintainer"><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 for our first-tier patrons.
1282
1274
 
1283
- * CKEditor ![CKEditor](https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/15452278/f8548dcf48d740619071e8d614459280/1?token-time=2145916800&token-hash=SIQ54PhIPHv3M7CVz9LxS8_8v4sOw4H304HaXsXj8MM%3D)
1284
1275
 
1276
+ * CKEditor ![](https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/15452278/f8548dcf48d740619071e8d614459280/1?token-time=2145916800&token-hash=SIQ54PhIPHv3M7CVz9LxS8_8v4sOw4H304HaXsXj8MM%3D)
1277
+ * 38elements ![](https://c10.patreonusercontent.com/3/eyJ3IjoyMDB9/patreon-media/p/user/12501844/88e7fc5dd62d45c6a5626533bbd48cfb/1?token-time=2145916800&token-hash=c3AsQ5T0IQWic0zKxFHu-bGGQJkXQFvafvJ4bPerFR4%3D)
package/bin/uglifyjs CHANGED
@@ -10,15 +10,13 @@ var info = require("../package.json");
10
10
  var path = require("path");
11
11
  var program = require("commander");
12
12
 
13
- var bundle_path = __dirname + "/../dist/bundle.js";
14
- if (!process.env.TERSER_NO_BUNDLE && fs.existsSync(bundle_path)) {
15
- var UglifyJS = require(bundle_path)
16
- try {
17
- require("source-map-support").install();
18
- } catch (err) {}
19
- } else {
20
- var UglifyJS = require("../tools/node.js");
21
- }
13
+ var bundle_path = __dirname + (process.env.TERSER_NO_BUNDLE ?
14
+ "/../dist/bundle.js" :
15
+ "/../dist/bundle.min.js");
16
+ var UglifyJS = require(bundle_path);
17
+ try {
18
+ require("source-map-support").install();
19
+ } catch (err) {}
22
20
 
23
21
  var skip_keys = [ "cname", "inlined", "parent_scope", "scope", "uses_eval", "uses_with" ];
24
22
  var files = {};
@@ -312,7 +310,7 @@ function simple_glob(glob) {
312
310
  if (Array.isArray(glob)) {
313
311
  return [].concat.apply([], glob.map(simple_glob));
314
312
  }
315
- if (glob && glob.match(/\*|\?/)) {
313
+ if (glob && glob.match(/[*?]/)) {
316
314
  var dir = path.dirname(glob);
317
315
  try {
318
316
  var entries = fs.readdirSync(dir);