terser 5.27.1 → 5.27.2
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.
- package/CHANGELOG.md +3 -0
- package/dist/bundle.min.js +13 -5
- package/lib/compress/drop-unused.js +14 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/bundle.min.js
CHANGED
@@ -15137,6 +15137,7 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
15137
15137
|
return node.expression;
|
15138
15138
|
}
|
15139
15139
|
};
|
15140
|
+
var this_def = null;
|
15140
15141
|
var in_use_ids = new Map();
|
15141
15142
|
var fixed_ids = new Map();
|
15142
15143
|
if (self instanceof AST_Toplevel && compressor.top_retain) {
|
@@ -15148,6 +15149,7 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
15148
15149
|
}
|
15149
15150
|
var var_defs_by_id = new Map();
|
15150
15151
|
var initializations = new Map();
|
15152
|
+
|
15151
15153
|
// pass 1: find out which symbols are directly used in
|
15152
15154
|
// this scope (not in nested scopes).
|
15153
15155
|
var scope = this;
|
@@ -15160,11 +15162,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
15160
15162
|
});
|
15161
15163
|
}
|
15162
15164
|
if (node === self) return;
|
15163
|
-
if (node instanceof AST_Class) {
|
15164
|
-
if (node.has_side_effects(compressor)) {
|
15165
|
-
node.visit_nondeferred_class_parts(tw);
|
15166
|
-
}
|
15167
|
-
}
|
15168
15165
|
if (node instanceof AST_Defun || node instanceof AST_DefClass) {
|
15169
15166
|
var node_def = node.name.definition();
|
15170
15167
|
const in_export = tw.parent() instanceof AST_Export;
|
@@ -15174,11 +15171,22 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
15174
15171
|
}
|
15175
15172
|
}
|
15176
15173
|
|
15174
|
+
if (node instanceof AST_DefClass && node.has_side_effects(compressor)) {
|
15175
|
+
const save_this_def = this_def;
|
15176
|
+
this_def = node_def;
|
15177
|
+
node.visit_nondeferred_class_parts(tw);
|
15178
|
+
this_def = save_this_def;
|
15179
|
+
}
|
15180
|
+
|
15177
15181
|
map_add(initializations, node_def.id, node);
|
15178
15182
|
return true; // don't go in nested scopes
|
15179
15183
|
}
|
15180
15184
|
// In the root scope, we drop things. In inner scopes, we just check for uses.
|
15181
15185
|
const in_root_scope = scope === self;
|
15186
|
+
if (node instanceof AST_This && this_def && in_root_scope) {
|
15187
|
+
in_use_ids.set(this_def.id, this_def);
|
15188
|
+
return true;
|
15189
|
+
}
|
15182
15190
|
if (node instanceof AST_SymbolFunarg && in_root_scope) {
|
15183
15191
|
map_add(var_defs_by_id, node.definition().id, node);
|
15184
15192
|
}
|
@@ -70,6 +70,7 @@ import {
|
|
70
70
|
AST_SymbolFunarg,
|
71
71
|
AST_SymbolRef,
|
72
72
|
AST_SymbolVar,
|
73
|
+
AST_This,
|
73
74
|
AST_Toplevel,
|
74
75
|
AST_Unary,
|
75
76
|
AST_Var,
|
@@ -126,6 +127,7 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
126
127
|
return node.expression;
|
127
128
|
}
|
128
129
|
};
|
130
|
+
var this_def = null;
|
129
131
|
var in_use_ids = new Map();
|
130
132
|
var fixed_ids = new Map();
|
131
133
|
if (self instanceof AST_Toplevel && compressor.top_retain) {
|
@@ -137,6 +139,7 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
137
139
|
}
|
138
140
|
var var_defs_by_id = new Map();
|
139
141
|
var initializations = new Map();
|
142
|
+
|
140
143
|
// pass 1: find out which symbols are directly used in
|
141
144
|
// this scope (not in nested scopes).
|
142
145
|
var scope = this;
|
@@ -149,11 +152,6 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
149
152
|
});
|
150
153
|
}
|
151
154
|
if (node === self) return;
|
152
|
-
if (node instanceof AST_Class) {
|
153
|
-
if (node.has_side_effects(compressor)) {
|
154
|
-
node.visit_nondeferred_class_parts(tw);
|
155
|
-
}
|
156
|
-
}
|
157
155
|
if (node instanceof AST_Defun || node instanceof AST_DefClass) {
|
158
156
|
var node_def = node.name.definition();
|
159
157
|
const in_export = tw.parent() instanceof AST_Export;
|
@@ -163,11 +161,22 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
|
163
161
|
}
|
164
162
|
}
|
165
163
|
|
164
|
+
if (node instanceof AST_DefClass && node.has_side_effects(compressor)) {
|
165
|
+
const save_this_def = this_def;
|
166
|
+
this_def = node_def;
|
167
|
+
node.visit_nondeferred_class_parts(tw);
|
168
|
+
this_def = save_this_def;
|
169
|
+
}
|
170
|
+
|
166
171
|
map_add(initializations, node_def.id, node);
|
167
172
|
return true; // don't go in nested scopes
|
168
173
|
}
|
169
174
|
// In the root scope, we drop things. In inner scopes, we just check for uses.
|
170
175
|
const in_root_scope = scope === self;
|
176
|
+
if (node instanceof AST_This && this_def && in_root_scope) {
|
177
|
+
in_use_ids.set(this_def.id, this_def);
|
178
|
+
return true;
|
179
|
+
}
|
171
180
|
if (node instanceof AST_SymbolFunarg && in_root_scope) {
|
172
181
|
map_add(var_defs_by_id, node.definition().id, node);
|
173
182
|
}
|