hoist_props: implement limited hoisting of class expressions (#2415)

This commit is contained in:
kzc
2017-10-30 11:20:54 -04:00
committed by Alex Lam S.L
parent d535daa2c7
commit 29bbc41dfe
2 changed files with 121 additions and 2 deletions

View File

@@ -619,7 +619,11 @@ merge(Compressor.prototype, {
function mark_escaped(d, node, value, level) {
var parent = tw.parent(level);
if (value instanceof AST_Constant || value instanceof AST_Function) return;
if (value instanceof AST_Constant
|| value instanceof AST_Function
|| value instanceof AST_ClassExpression) {
return;
}
if (parent instanceof AST_Assign && parent.operator == "=" && node === parent.right
|| parent instanceof AST_Call && node !== parent.expression
|| parent instanceof AST_Return && node === parent.value && node.scope !== d.scope
@@ -4043,7 +4047,8 @@ merge(Compressor.prototype, {
function is_object(node) {
return node instanceof AST_Array
|| node instanceof AST_Lambda
|| node instanceof AST_Object;
|| node instanceof AST_Object
|| node instanceof AST_Class;
}
OPT(AST_Binary, function(self, compressor){