uglify-js
Advanced tools
Comparing version 3.12.8 to 3.13.0
@@ -48,2 +48,3 @@ /*********************************************************************** | ||
this.eliminated = 0; | ||
this.exported = false; | ||
this.global = false; | ||
@@ -95,2 +96,3 @@ this.id = id; | ||
return this.global && !options.toplevel | ||
|| this.exported | ||
|| this.undeclared | ||
@@ -111,2 +113,3 @@ || !options.eval && this.scope.pinned() | ||
if (parent instanceof AST_DestructuredKeyVal) return node; | ||
if (parent instanceof AST_ForEnumeration) return parent.init === node && node; | ||
if (parent instanceof AST_Unary) return unary_side_effects[parent.operator] && parent.expression; | ||
@@ -124,7 +127,31 @@ } | ||
var defun = null; | ||
var exported = false; | ||
var next_def_id = 0; | ||
var scope = self.parent_scope = null; | ||
var tw = new TreeWalker(function(node, descend) { | ||
if (node instanceof AST_DefClass) { | ||
var save_exported = exported; | ||
exported = tw.parent() instanceof AST_ExportDeclaration; | ||
node.name.walk(tw); | ||
exported = save_exported; | ||
walk_scope(function() { | ||
if (node.extends) node.extends.walk(tw); | ||
node.properties.forEach(function(prop) { | ||
prop.walk(tw); | ||
}); | ||
}); | ||
return true; | ||
} | ||
if (node instanceof AST_Definitions) { | ||
var save_exported = exported; | ||
exported = tw.parent() instanceof AST_ExportDeclaration; | ||
descend(); | ||
exported = save_exported; | ||
return true; | ||
} | ||
if (node instanceof AST_LambdaDefinition) { | ||
var save_exported = exported; | ||
exported = tw.parent() instanceof AST_ExportDeclaration; | ||
node.name.walk(tw); | ||
exported = save_exported; | ||
walk_scope(function() { | ||
@@ -176,5 +203,7 @@ node.argnames.forEach(function(argname) { | ||
} else if (node instanceof AST_SymbolConst) { | ||
scope.def_variable(node).defun = defun; | ||
var def = scope.def_variable(node); | ||
def.defun = defun; | ||
def.exported = exported; | ||
} else if (node instanceof AST_SymbolDefun) { | ||
defun.def_function(node, tw.parent()); | ||
defun.def_function(node, tw.parent()).exported = exported; | ||
entangle(defun, scope); | ||
@@ -188,5 +217,5 @@ } else if (node instanceof AST_SymbolFunarg) { | ||
} else if (node instanceof AST_SymbolLet) { | ||
scope.def_variable(node); | ||
scope.def_variable(node).exported = exported; | ||
} else if (node instanceof AST_SymbolVar) { | ||
defun.def_variable(node, null); | ||
defun.def_variable(node, node instanceof AST_SymbolImport ? undefined : null).exported = exported; | ||
entangle(defun, scope); | ||
@@ -308,2 +337,9 @@ } | ||
} | ||
if (sym.init instanceof AST_LambdaDefinition && sym.scope !== sym.init.name.scope) { | ||
var scope = node.scope; | ||
do { | ||
if (scope === sym.init.name.scope) break; | ||
} while (scope = scope.parent_scope); | ||
if (!scope) sym.init = undefined; | ||
} | ||
node.thedef = sym; | ||
@@ -428,3 +464,5 @@ node.reference(options); | ||
push_uniq(s.enclosed, def); | ||
if (options.keep_fnames) { | ||
if (!options) { | ||
delete s._var_names; | ||
} else if (options.keep_fnames) { | ||
s.functions.each(function(d) { | ||
@@ -431,0 +469,0 @@ push_uniq(def.scope.enclosed, d); |
@@ -150,2 +150,11 @@ /*********************************************************************** | ||
DEF(AST_AsyncArrow, transform_arrow); | ||
DEF(AST_Class, function(self, tw) { | ||
if (self.name) self.name = self.name.transform(tw); | ||
if (self.extends) self.extends = self.extends.transform(tw); | ||
self.properties = do_list(self.properties, tw); | ||
}); | ||
DEF(AST_ClassProperty, function(self, tw) { | ||
if (self.key instanceof AST_Node) self.key = self.key.transform(tw); | ||
if (self.value) self.value = self.value.transform(tw); | ||
}); | ||
DEF(AST_Call, function(self, tw) { | ||
@@ -208,2 +217,16 @@ self.expression = self.expression.transform(tw); | ||
}); | ||
DEF(AST_ExportDeclaration, function(self, tw) { | ||
self.body = self.body.transform(tw); | ||
}); | ||
DEF(AST_ExportDefault, function(self, tw) { | ||
self.body = self.body.transform(tw); | ||
}); | ||
DEF(AST_ExportReferences, function(self, tw) { | ||
self.properties = do_list(self.properties, tw); | ||
}); | ||
DEF(AST_Import, function(self, tw) { | ||
if (self.all) self.all = self.all.transform(tw); | ||
if (self.default) self.default = self.default.transform(tw); | ||
if (self.properties) self.properties = do_list(self.properties, tw); | ||
}); | ||
DEF(AST_Template, function(self, tw) { | ||
@@ -210,0 +233,0 @@ if (self.tag) self.tag = self.tag.transform(tw); |
@@ -241,3 +241,3 @@ /*********************************************************************** | ||
// a statement. | ||
function first_in_statement(stack, arrow) { | ||
function first_in_statement(stack, arrow, export_default) { | ||
var node = stack.parent(-1); | ||
@@ -253,2 +253,4 @@ for (var i = 0, p; p = stack.parent(i++); node = p) { | ||
if (p.condition === node) continue; | ||
} else if (p instanceof AST_ExportDefault) { | ||
return export_default; | ||
} else if (p instanceof AST_PropAccess) { | ||
@@ -258,4 +260,4 @@ if (p.expression === node) continue; | ||
if (p.expressions[0] === node) continue; | ||
} else if (p instanceof AST_Statement) { | ||
return p.body === node; | ||
} else if (p instanceof AST_SimpleStatement) { | ||
return true; | ||
} else if (p instanceof AST_Template) { | ||
@@ -262,0 +264,0 @@ if (p.tag === node) continue; |
@@ -6,3 +6,3 @@ { | ||
"license": "BSD-2-Clause", | ||
"version": "3.12.8", | ||
"version": "3.13.0", | ||
"engines": { | ||
@@ -9,0 +9,0 @@ "node": ">=0.8.0" |
@@ -7,8 +7,7 @@ UglifyJS 3 | ||
#### Note: | ||
- **`uglify-js@3` has a simplified [API](#api-reference) and [CLI](#command-line-usage) | ||
that is not backwards compatible with [`uglify-js@2`](https://github.com/mishoo/UglifyJS/tree/v2.x)**. | ||
- **Documentation for UglifyJS `2.x` releases can be found [here](https://github.com/mishoo/UglifyJS/tree/v2.x)**. | ||
- `uglify-js` supports ECMAScript 5 and some newer language features. | ||
- To minify ECMAScript 2015 or above, you may need to transpile using tools like | ||
[Babel](https://babeljs.io/). | ||
- `uglify-js` supports JavaScript and most language features in ECMAScript. | ||
- For more exotic parts of ECMAScript, process your source file with transpilers | ||
like [Babel](https://babeljs.io/) before passing onto `uglify-js`. | ||
- `uglify-js@3` has a simplified [API](#api-reference) and [CLI](#command-line-usage) | ||
that is not backwards compatible with [`uglify-js@2`](https://github.com/mishoo/UglifyJS/tree/v2.x). | ||
@@ -90,3 +89,3 @@ Install | ||
3 - original | ||
`wrap_iife` Wrap IIFEs in parenthesis. Note: you may | ||
`wrap_iife` Wrap IIFEs in parentheses. Note: you may | ||
want to disable `negate_iife` under | ||
@@ -672,3 +671,3 @@ compressor options. | ||
- `functions` (default: `true`) -- convert declarations from `var`to `function` | ||
- `functions` (default: `true`) -- convert declarations from `var` to `function` | ||
whenever possible. | ||
@@ -678,2 +677,5 @@ | ||
- `hoist_exports` (default: `true`) -- hoist `export` statements to facilitate | ||
various `compress` and `mangle` optimizations. | ||
- `hoist_funs` (default: `false`) -- hoist function declarations | ||
@@ -692,2 +694,4 @@ | ||
- `imports` (default: `true`) -- drop unreferenced import symbols when used with `unused` | ||
- `inline` (default: `true`) -- inline calls to function with simple/`return` statement: | ||
@@ -694,0 +698,0 @@ - `false` -- same as `0` |
exports["Dictionary"] = Dictionary; | ||
exports["is_statement"] = is_statement; | ||
exports["List"] = List; | ||
@@ -3,0 +4,0 @@ exports["minify"] = minify; |
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
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1095792
28032
1288