terser 4.1.2 → 4.2.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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## v4.2.1
4
+
5
+ - Minor refactors
6
+ - Fixed a bug similar to #369 in collapse_vars
7
+ - Functions can no longer be inlined into a place where they're going to be compared with themselves.
8
+ - reduce_funcs option is now legacy, as using reduce_vars without reduce_funcs caused some weird corner cases. As a result, it is now implied in reduce_vars and can't be turned off without turning off reduce_vars.
9
+ - Bug which would cause a random stack overflow has now been fixed.
10
+
11
+ ## v4.2.0
12
+
13
+ - When the source map URL is `inline`, don't write it to a file.
14
+ - Fixed output parens when a lambda literal is the tag on a tagged template string.
15
+ - The `mangle.properties.undeclared` option was added. This enables the property mangler to mangle properties of variables which can be found in the name cache, but whose properties are not known to this Terser run.
16
+ - The v8 bug where the toString and source representations of regexes like `RegExp("\\\n")` includes an actual newline is now fixed.
17
+ - Now we're guaranteed to not have duplicate comments in the output
18
+ - Domprops updates
19
+
20
+ ## v4.1.4
21
+
22
+ - Fixed a crash when inlining a function into somewhere else when it has interdependent, non-removable variables.
23
+
24
+ ## v4.1.3
25
+
26
+ - Several issues with the `reduce_vars` option were fixed.
27
+ - Starting this version, we only have a dist/bundle.min.js
3
28
 
4
29
  ## v4.1.2
5
30
 
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
- terser
2
- ======
1
+ <h1><img src="https://raw.githubusercontent.com/terser-js/terser/master/logo.svg?sanitize=true" alt="Terser" width="450" height="190"></h1>
3
2
 
4
- ![Terser](https://raw.githubusercontent.com/terser-js/terser/master/logo.png)
3
+ [![NPM Version][npm-image]][npm-url]
4
+ [![NPM Downloads][downloads-image]][downloads-url]
5
+ [![Linux Build][travis-image]][travis-url]
5
6
 
6
7
  A JavaScript parser and mangler/compressor toolkit for ES6+.
7
8
 
@@ -11,12 +12,16 @@ Terser recommends you use RollupJS to bundle your modules, as that produces smal
11
12
 
12
13
  *Beautification* has been undocumented and is *being removed* from terser, we recommend you use [prettier](https://npmjs.com/package/prettier).
13
14
 
14
- [![Build Status](https://travis-ci.org/terser-js/terser.svg?branch=master)](https://travis-ci.org/terser-js/terser)
15
-
16
15
  Find the changelog in [CHANGELOG.md](https://github.com/terser-js/terser/blob/master/CHANGELOG.md)
17
16
 
18
17
  A JavaScript parser, mangler/compressor and beautifier toolkit for ES6+.
19
18
 
19
+ [npm-image]: https://img.shields.io/npm/v/terser.svg
20
+ [npm-url]: https://npmjs.org/package/terser
21
+ [downloads-image]: https://img.shields.io/npm/dm/terser.svg
22
+ [downloads-url]: https://npmjs.org/package/terser
23
+ [travis-image]: https://img.shields.io/travis/terser-js/terser/master.svg
24
+ [travis-url]: https://travis-ci.org/terser-js/terser
20
25
 
21
26
  Why choose terser?
22
27
  ------------------
@@ -39,7 +44,7 @@ From NPM for use as a command line app:
39
44
  From NPM for programmatic use:
40
45
 
41
46
  npm install terser
42
-
47
+
43
48
  # Command line usage
44
49
 
45
50
  terser [input files] [options]
@@ -255,7 +260,7 @@ way to use this is to use the `regex` option like so:
255
260
  terser example.js -c -m --mangle-props regex=/_$/
256
261
  ```
257
262
 
258
- This will mangle all properties that start with an
263
+ This will mangle all properties that start with an
259
264
  underscore. So you can use it to mangle internal methods.
260
265
 
261
266
  By default, it will mangle all properties in the
@@ -525,7 +530,7 @@ if (result.error) throw result.error;
525
530
  ## Minify options
526
531
 
527
532
  - `ecma` (default `undefined`) - pass `5`, `6`, `7` or `8` to override `parse`,
528
- `compress` and `output` options.
533
+ `compress` and `output`'s `ecma` options.
529
534
 
530
535
  - `warnings` (default `false`) — pass `true` to return compressor warnings
531
536
  in `result.warnings`. Use the value `"verbose"` for more detailed warnings.
@@ -797,11 +802,7 @@ If you're using the `X-SourceMap` header instead, you can just omit `sourceMap.u
797
802
  Specify `"strict"` to treat `foo.bar` as side-effect-free only when
798
803
  `foo` is certain to not throw, i.e. not `null` or `undefined`.
799
804
 
800
- - `reduce_funcs` (default: `true`) -- Allows single-use functions to be
801
- inlined as function expressions when permissible allowing further
802
- optimization. Enabled by default. Option depends on `reduce_vars`
803
- being enabled. Some code runs faster in the Chrome V8 engine if this
804
- option is disabled. Does not negatively impact other major browsers.
805
+ - `reduce_funcs` (legacy option, safely ignored for backwards compatibility).
805
806
 
806
807
  - `reduce_vars` (default: `true`) -- Improve optimization on variables assigned with and
807
808
  used as constant values.
@@ -948,6 +949,11 @@ Terser.minify(code, { mangle: { toplevel: true } }).code;
948
949
  - `reserved` (default: `[]`) — Do not mangle property names listed in the
949
950
  `reserved` array.
950
951
 
952
+ - `undeclared` (default: `false`) - Mangle those names when they are accessed
953
+ as properties of known top level variables but their declarations are never
954
+ found in input code. May be useful when only minifying parts of a project.
955
+ See [#397](https://github.com/terser-js/terser/issues/397) for more details.
956
+
951
957
  ## Output options
952
958
 
953
959
  The code generator tries to output shortest code possible by default. In
package/bin/uglifyjs CHANGED
@@ -11,10 +11,7 @@ var info = require("../package.json");
11
11
  var path = require("path");
12
12
  var program = require("commander");
13
13
 
14
- var bundle_path = __dirname + (process.env.TERSER_NO_BUNDLE ?
15
- "/../dist/bundle.js" :
16
- "/../dist/bundle.min.js");
17
- var UglifyJS = require(bundle_path);
14
+ var UglifyJS = require("..");
18
15
  try {
19
16
  require("source-map-support").install();
20
17
  } catch (err) {}
@@ -297,7 +294,7 @@ function run() {
297
294
  }).ast.to_mozilla_ast(), null, 2));
298
295
  } else if (program.output) {
299
296
  fs.writeFileSync(program.output, result.code);
300
- if (result.map) {
297
+ if (options.sourceMap.url !== "inline" && result.map) {
301
298
  fs.writeFileSync(program.output + ".map", result.map);
302
299
  }
303
300
  } else {