uglify-js
Advanced tools
Comparing version 3.15.5 to 3.16.0
@@ -84,2 +84,3 @@ "use strict"; | ||
mangle: {}, | ||
module: false, | ||
nameCache: null, | ||
@@ -91,3 +92,3 @@ output: {}, | ||
timings: false, | ||
toplevel: false, | ||
toplevel: !!(options && options["module"]), | ||
v8: false, | ||
@@ -106,2 +107,3 @@ validate: false, | ||
if (options.keep_fnames) set_shorthand("keep_fnames", options, [ "compress", "mangle", "rename" ]); | ||
if (options.module) set_shorthand("module", options, [ "compress", "parse" ]); | ||
if (options.toplevel) set_shorthand("toplevel", options, [ "compress", "mangle", "rename" ]); | ||
@@ -108,0 +110,0 @@ if (options.v8) set_shorthand("v8", options, [ "mangle", "output", "rename" ]); |
@@ -67,6 +67,9 @@ /*********************************************************************** | ||
mangle: function(options) { | ||
var cache = options.cache && options.cache.props; | ||
if (this.global && cache && cache.has(this.name)) { | ||
if (this.mangled_name) return; | ||
var cache = this.global && options.cache && options.cache.props; | ||
if (cache && cache.has(this.name)) { | ||
this.mangled_name = cache.get(this.name); | ||
} else if (!this.mangled_name && !this.unmangleable(options)) { | ||
} else if (this.unmangleable(options)) { | ||
names_in_use(this.scope, options).set(this.name, true); | ||
} else { | ||
var def = this.redefined(); | ||
@@ -78,5 +81,3 @@ if (def) { | ||
} | ||
if (this.global && cache) { | ||
cache.set(this.name, this.mangled_name); | ||
} | ||
if (cache) cache.set(this.name, this.mangled_name); | ||
} | ||
@@ -626,10 +627,6 @@ }, | ||
var tw = new TreeWalker(function(node, descend) { | ||
if (node instanceof AST_LabeledStatement) { | ||
var save_nesting; | ||
if (node instanceof AST_BlockScope) { | ||
// `lname` is incremented when we get to the `AST_Label` | ||
var save_nesting = lname; | ||
descend(); | ||
if (!options.v8 || !in_label(tw)) lname = save_nesting; | ||
return true; | ||
} | ||
if (node instanceof AST_BlockScope) { | ||
if (node instanceof AST_LabeledStatement) save_nesting = lname; | ||
if (options.webkit && node instanceof AST_IterationStatement && node.init instanceof AST_Let) { | ||
@@ -680,2 +677,3 @@ node.init.definitions.forEach(function(defn) { | ||
to_mangle.forEach(mangle); | ||
if (node instanceof AST_LabeledStatement && !(options.v8 && in_label(tw))) lname = save_nesting; | ||
return true; | ||
@@ -682,0 +680,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
"license": "BSD-2-Clause", | ||
"version": "3.15.5", | ||
"version": "3.16.0", | ||
"engines": { | ||
@@ -9,0 +9,0 @@ "node": ">=0.8.0" |
@@ -121,2 +121,3 @@ UglifyJS 3 | ||
code relying on Function.prototype.name. | ||
--module Process input as ES module (implies --toplevel) | ||
--name-cache <file> File to hold mangled name mappings. | ||
@@ -150,3 +151,3 @@ --self Build UglifyJS as a library (implies --wrap UglifyJS) | ||
Equivalent to setting `webkit: true` in `minify()` | ||
for `mangle` and `output` options. | ||
for `compress`, `mangle` and `output` options. | ||
By default UglifyJS will not try to be Safari-proof. | ||
@@ -522,2 +523,5 @@ --wrap <name> Embed everything in a big function, making the | ||
- `module` (default: `false`) — set to `true` if you wish to process input as | ||
ES module, i.e. implicit `"use strict";` alongside with `toplevel` enabled. | ||
- `nameCache` (default: `null`) — pass an empty object `{}` or a previously | ||
@@ -734,2 +738,5 @@ used `nameCache` object if you wish to cache mangled variable and | ||
- `module` (default: `false`) — set to `true` if you wish to process input as | ||
ES module, i.e. implicit `"use strict";` alongside with `toplevel` enabled. | ||
- `negate_iife` (default: `true`) — negate "Immediately-Called Function Expressions" | ||
@@ -1338,6 +1345,4 @@ where the return value is discarded, to avoid the parens that the | ||
var await; | ||
async function f() { | ||
class A { | ||
static p = await; | ||
} | ||
class A { | ||
static p = await; | ||
} | ||
@@ -1397,1 +1402,28 @@ // SyntaxError: Unexpected reserved word | ||
UglifyJS may modify the input which in turn may suppress those errors. | ||
- Some versions of Chrome and Node.js will give incorrect results with the | ||
following: | ||
```javascript | ||
(async function(a) { | ||
(function() { | ||
var b = await => console.log("PASS"); | ||
b(); | ||
})(); | ||
})().catch(console.error); | ||
// Expected: "PASS" | ||
// Actual: SyntaxError: Unexpected reserved word | ||
``` | ||
UglifyJS may modify the input which in turn may suppress those errors. | ||
- Later versions of Chrome and Node.js will give incorrect results with the | ||
following: | ||
```javascript | ||
try { | ||
f(); | ||
function f() { | ||
throw 42; | ||
} | ||
} catch (e) {} | ||
console.log(typeof f); | ||
// Expected: "function" | ||
// Actual: "undefined" | ||
``` | ||
UglifyJS may modify the input which in turn may suppress those errors. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1243383
31162
1424