terser 5.17.2 → 5.17.3
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 +4 -0
- package/dist/bundle.min.js +22 -13
- package/lib/compress/drop-side-effect-free.js +9 -0
- package/lib/compress/index.js +0 -13
- package/lib/compress/inference.js +14 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v5.17.3
|
4
|
+
|
5
|
+
- Fix issue with trimming a static class property's contents accessing the class as `this`.
|
6
|
+
|
3
7
|
## v5.17.2
|
4
8
|
- Be less conservative when detecting use-before-definition of `var` in hoisted functions.
|
5
9
|
- Support unusual (but perfectly valid) initializers of for-in and for-of loops.
|
package/dist/bundle.min.js
CHANGED
@@ -14155,6 +14155,19 @@ const aborts = (thing) => thing && thing.aborts();
|
|
14155
14155
|
node.DEFMETHOD("aborts", func);
|
14156
14156
|
});
|
14157
14157
|
|
14158
|
+
AST_Node.DEFMETHOD("contains_this", function() {
|
14159
|
+
return walk(this, node => {
|
14160
|
+
if (node instanceof AST_This) return walk_abort;
|
14161
|
+
if (
|
14162
|
+
node !== this
|
14163
|
+
&& node instanceof AST_Scope
|
14164
|
+
&& !(node instanceof AST_Arrow)
|
14165
|
+
) {
|
14166
|
+
return true;
|
14167
|
+
}
|
14168
|
+
});
|
14169
|
+
});
|
14170
|
+
|
14158
14171
|
function is_modified(compressor, tw, node, value, level, immutable) {
|
14159
14172
|
var parent = tw.parent(level);
|
14160
14173
|
var lhs = is_lhs(node, parent);
|
@@ -14760,6 +14773,15 @@ def_drop_side_effect_free(AST_Class, function (compressor) {
|
|
14760
14773
|
}
|
14761
14774
|
}
|
14762
14775
|
|
14776
|
+
if (
|
14777
|
+
prop instanceof AST_ClassProperty
|
14778
|
+
&& prop.static
|
14779
|
+
&& prop.value.has_side_effects(compressor)
|
14780
|
+
&& prop.contains_this()
|
14781
|
+
) {
|
14782
|
+
return this;
|
14783
|
+
}
|
14784
|
+
|
14763
14785
|
const trimmed_prop = prop.drop_side_effect_free(compressor);
|
14764
14786
|
if (trimmed_prop)
|
14765
14787
|
with_effects.push(trimmed_prop);
|
@@ -21229,19 +21251,6 @@ def_optimize(AST_Chain, function (self, compressor) {
|
|
21229
21251
|
return self;
|
21230
21252
|
});
|
21231
21253
|
|
21232
|
-
AST_Lambda.DEFMETHOD("contains_this", function() {
|
21233
|
-
return walk(this, node => {
|
21234
|
-
if (node instanceof AST_This) return walk_abort;
|
21235
|
-
if (
|
21236
|
-
node !== this
|
21237
|
-
&& node instanceof AST_Scope
|
21238
|
-
&& !(node instanceof AST_Arrow)
|
21239
|
-
) {
|
21240
|
-
return true;
|
21241
|
-
}
|
21242
|
-
});
|
21243
|
-
});
|
21244
|
-
|
21245
21254
|
def_optimize(AST_Dot, function(self, compressor) {
|
21246
21255
|
const parent = compressor.parent();
|
21247
21256
|
if (is_lhs(self, parent)) return self;
|
@@ -165,6 +165,15 @@ def_drop_side_effect_free(AST_Class, function (compressor) {
|
|
165
165
|
}
|
166
166
|
}
|
167
167
|
|
168
|
+
if (
|
169
|
+
prop instanceof AST_ClassProperty
|
170
|
+
&& prop.static
|
171
|
+
&& prop.value.has_side_effects(compressor)
|
172
|
+
&& prop.contains_this()
|
173
|
+
) {
|
174
|
+
return this;
|
175
|
+
}
|
176
|
+
|
168
177
|
const trimmed_prop = prop.drop_side_effect_free(compressor);
|
169
178
|
if (trimmed_prop)
|
170
179
|
with_effects.push(trimmed_prop);
|
package/lib/compress/index.js
CHANGED
@@ -3358,19 +3358,6 @@ def_optimize(AST_Chain, function (self, compressor) {
|
|
3358
3358
|
return self;
|
3359
3359
|
});
|
3360
3360
|
|
3361
|
-
AST_Lambda.DEFMETHOD("contains_this", function() {
|
3362
|
-
return walk(this, node => {
|
3363
|
-
if (node instanceof AST_This) return walk_abort;
|
3364
|
-
if (
|
3365
|
-
node !== this
|
3366
|
-
&& node instanceof AST_Scope
|
3367
|
-
&& !(node instanceof AST_Arrow)
|
3368
|
-
) {
|
3369
|
-
return true;
|
3370
|
-
}
|
3371
|
-
});
|
3372
|
-
});
|
3373
|
-
|
3374
3361
|
def_optimize(AST_Dot, function(self, compressor) {
|
3375
3362
|
const parent = compressor.parent();
|
3376
3363
|
if (is_lhs(self, parent)) return self;
|
@@ -84,6 +84,7 @@ import {
|
|
84
84
|
AST_PropAccess,
|
85
85
|
AST_RegExp,
|
86
86
|
AST_Return,
|
87
|
+
AST_Scope,
|
87
88
|
AST_Sequence,
|
88
89
|
AST_SimpleStatement,
|
89
90
|
AST_Statement,
|
@@ -950,6 +951,19 @@ export const aborts = (thing) => thing && thing.aborts();
|
|
950
951
|
node.DEFMETHOD("aborts", func);
|
951
952
|
});
|
952
953
|
|
954
|
+
AST_Node.DEFMETHOD("contains_this", function() {
|
955
|
+
return walk(this, node => {
|
956
|
+
if (node instanceof AST_This) return walk_abort;
|
957
|
+
if (
|
958
|
+
node !== this
|
959
|
+
&& node instanceof AST_Scope
|
960
|
+
&& !(node instanceof AST_Arrow)
|
961
|
+
) {
|
962
|
+
return true;
|
963
|
+
}
|
964
|
+
});
|
965
|
+
});
|
966
|
+
|
953
967
|
export function is_modified(compressor, tw, node, value, level, immutable) {
|
954
968
|
var parent = tw.parent(level);
|
955
969
|
var lhs = is_lhs(node, parent);
|