improve class compatibility in side_effects (#5279)

This commit is contained in:
Alex Lam S.L
2022-01-09 13:15:42 +00:00
committed by GitHub
parent f473b4db38
commit e9d9d5a9d2
3 changed files with 265 additions and 22 deletions

View File

@@ -8290,17 +8290,26 @@ Compressor.prototype.compress = function(node) {
if (!base && !values) return null;
exprs = [];
}
if (base) {
if (base || !compressor.has_directive("use strict")) {
var node = to_class_expr(self, true);
if (!base) node.extends = null;
node.properties = [];
if (exprs.length) node.properties.push(make_node(AST_ClassMethod, self, {
key: make_sequence(self, exprs),
value: make_node(AST_Function, self, {
argnames: [],
body: [],
}).init_vars(node),
}));
exprs = [ node ];
if (values) {
node.properties.push(make_node(AST_ClassField, self, {
static: true,
key: exprs.length ? make_sequence(self, exprs) : "c",
value: make_sequence(self, values),
}));
} else if (exprs.length) {
node.properties.push(make_node(AST_ClassMethod, self, {
key: make_sequence(self, exprs),
value: make_node(AST_Function, self, {
argnames: [],
body: [],
}).init_vars(node),
}));
}
return node;
}
if (values) exprs.push(make_node(AST_Call, self, {
expression: make_node(AST_Arrow, self, {