terser
Advanced tools
Comparing version 5.29.2 to 5.30.0
# Changelog | ||
## v5.20.0 | ||
- Improve removal of classes referring to themselves | ||
## v5.29.2 | ||
@@ -4,0 +7,0 @@ - Make sure 'computed_props' creates string keys |
@@ -158,5 +158,9 @@ /*********************************************************************** | ||
const with_effects = []; | ||
if (this.is_self_referential() && this.has_side_effects(compressor)) { | ||
return this; | ||
} | ||
const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor); | ||
if (trimmed_extends) | ||
with_effects.push(trimmed_extends); | ||
if (trimmed_extends) with_effects.push(trimmed_extends); | ||
@@ -170,7 +174,3 @@ for (const prop of this.properties) { | ||
const trimmed_prop = prop.drop_side_effect_free(compressor); | ||
if (trimmed_prop) { | ||
if (trimmed_prop.contains_this()) return this; | ||
with_effects.push(trimmed_prop); | ||
} | ||
if (trimmed_prop) with_effects.push(trimmed_prop); | ||
} | ||
@@ -177,0 +177,0 @@ } |
@@ -73,3 +73,2 @@ /*********************************************************************** | ||
AST_SymbolVar, | ||
AST_This, | ||
AST_Toplevel, | ||
@@ -131,3 +130,2 @@ AST_Unary, | ||
}; | ||
var this_def = null; | ||
var in_use_ids = new Map(); | ||
@@ -144,2 +142,3 @@ var fixed_ids = new Map(); | ||
var initializations = new Map(); | ||
var self_referential_classes = new Set(); | ||
@@ -158,2 +157,6 @@ // pass 1: find out which symbols are directly used in | ||
if (node === self) return; | ||
if (node instanceof AST_Class && node.has_side_effects(compressor)) { | ||
if (node.is_self_referential()) self_referential_classes.add(node); | ||
node.visit_nondeferred_class_parts(tw); | ||
} | ||
if (node instanceof AST_Defun || node instanceof AST_DefClass) { | ||
@@ -168,9 +171,2 @@ var node_def = node.name.definition(); | ||
if (node instanceof AST_DefClass && node.has_side_effects(compressor)) { | ||
const save_this_def = this_def; | ||
this_def = node_def; | ||
node.visit_nondeferred_class_parts(tw); | ||
this_def = save_this_def; | ||
} | ||
map_add(initializations, node_def.id, node); | ||
@@ -181,6 +177,2 @@ return true; // don't go in nested scopes | ||
const in_root_scope = scope === self; | ||
if (node instanceof AST_This && this_def && in_root_scope) { | ||
in_use_ids.set(this_def.id, this_def); | ||
return true; | ||
} | ||
if (node instanceof AST_SymbolFunarg && in_root_scope) { | ||
@@ -234,2 +226,5 @@ map_add(var_defs_by_id, node.definition().id, node); | ||
}); | ||
self_referential_classes.forEach(function (cls) { | ||
cls.walk(tw); | ||
}); | ||
// pass 3: we should drop declarations not in_use | ||
@@ -236,0 +231,0 @@ var tt = new TreeTransformer( |
@@ -7,3 +7,3 @@ { | ||
"license": "BSD-2-Clause", | ||
"version": "5.29.2", | ||
"version": "5.30.0", | ||
"engines": { | ||
@@ -10,0 +10,0 @@ "node": ">=10" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2151568
61053