aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-06-03 13:23:14 +0100
committerGitHub <noreply@github.com>2021-06-03 20:23:14 +0800
commit83f7887e5d2eb58b3fdbfc1d0d7dd92ce972a105 (patch)
tree19e4abb90f94290284264cdd7bee7b4bfd9cdfd2 /lib
parentdff7b48921cd90d23f05678c08e2065d9390b07b (diff)
downloadtracifyjs-83f7887e5d2eb58b3fdbfc1d0d7dd92ce972a105.tar.gz
tracifyjs-83f7887e5d2eb58b3fdbfc1d0d7dd92ce972a105.zip
fix corner case in `unused` (#4993)
fixes #4992
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/compress.js b/lib/compress.js
index b20a41e5..73cc2df5 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1029,12 +1029,12 @@ merge(Compressor.prototype, {
if (prop.key instanceof AST_Node) prop.key.walk(tw);
return prop.value;
}).forEach(function(prop) {
- if (prop.static && (prop.value instanceof AST_Lambda || !prop.value.contains_this())) {
- prop.value.walk(tw);
- } else {
+ if (!prop.static || prop instanceof AST_ClassField && prop.value.contains_this()) {
push(tw);
prop.value.walk(tw);
pop(tw);
+ } else {
+ prop.value.walk(tw);
}
});
return true;
@@ -6185,12 +6185,6 @@ merge(Compressor.prototype, {
}
return true;
}
- } else if (node instanceof AST_This && scope instanceof AST_DefClass) {
- var def = scope.name.definition();
- if (!(def.id in in_use_ids)) {
- in_use_ids[def.id] = true;
- in_use.push(def);
- }
}
return scan_ref_scoped(node, descend, true);
});
@@ -7703,10 +7697,9 @@ merge(Compressor.prototype, {
for (var i = 0; i < props.length; i++) {
var prop = props[i];
if (prop.key instanceof AST_Node) exprs.push(prop.key);
- if (prop instanceof AST_ClassField
- && prop.static
- && prop.value
- && !(prop.value instanceof AST_Lambda)) {
+ if (prop.static && prop.value
+ && prop instanceof AST_ClassField
+ && prop.value.has_side_effects(compressor)) {
if (prop.value.contains_this()) return this;
values.push(prop.value);
}