@@ -2474,8 +2474,10 @@ Compressor.prototype.compress = function(node) {
|
||||
if (node instanceof AST_Scope) return node;
|
||||
// Scan computed keys, static fields & initializers in class
|
||||
if (node instanceof AST_Class) {
|
||||
if (node.name) node.name = node.name.transform(tt);
|
||||
if (!abort && node.extends) node.extends = node.extends.transform(tt);
|
||||
var replace = can_replace;
|
||||
can_replace = false;
|
||||
if (node.name) node.name.transform(tt);
|
||||
if (!abort && node.extends) node.extends.transform(tt);
|
||||
var fields = [], stats = [];
|
||||
for (var i = 0; !abort && i < node.properties.length; i++) {
|
||||
var prop = node.properties[i];
|
||||
@@ -2491,9 +2493,9 @@ Compressor.prototype.compress = function(node) {
|
||||
stats[i].transform(tt);
|
||||
}
|
||||
for (var i = 0; !abort && i < fields.length; i++) {
|
||||
var prop = fields[i];
|
||||
prop.value = prop.value.transform(tt);
|
||||
fields[i].value.transform(tt);
|
||||
}
|
||||
can_replace = replace;
|
||||
return node;
|
||||
}
|
||||
// Scan object only in a for-in/of statement
|
||||
|
||||
@@ -1165,9 +1165,9 @@ collapse_rhs_static: {
|
||||
"use strict";
|
||||
var a = "FAIL";
|
||||
class A {
|
||||
static p = a = "PASS";
|
||||
static p = "PASS";
|
||||
}
|
||||
console.log(a);
|
||||
console.log(a = "PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=12"
|
||||
@@ -3974,3 +3974,59 @@ issue_5735_2: {
|
||||
]
|
||||
node_version: ">=12"
|
||||
}
|
||||
|
||||
issue_5747_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
(async function() {
|
||||
var a = await 42;
|
||||
class A {
|
||||
static P = a && console.log(typeof this);
|
||||
}
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
(async function() {
|
||||
var a = await 42;
|
||||
class A {
|
||||
static P = a && console.log(typeof this);
|
||||
}
|
||||
})();
|
||||
}
|
||||
expect_stdout: "function"
|
||||
node_version: ">=12"
|
||||
}
|
||||
|
||||
issue_5747_2: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
(async function() {
|
||||
var a = await 42;
|
||||
class A {
|
||||
static {
|
||||
a && console.log(typeof this);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
(async function() {
|
||||
var a = await 42;
|
||||
class A {
|
||||
static {
|
||||
a && console.log(typeof this);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
expect_stdout: "function"
|
||||
node_version: ">=16"
|
||||
}
|
||||
|
||||
@@ -539,7 +539,9 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
var before_iterations, diff_error_message, passes = 3, testcase_ast;
|
||||
for (var pass = 1; pass <= passes; pass++) {
|
||||
if (before_iterations !== testcase) {
|
||||
testcase_ast = U.parse(testcase);
|
||||
testcase_ast = U.parse(testcase, {
|
||||
module: minify_options.module,
|
||||
});
|
||||
if (diff_error_message === testcase) {
|
||||
// only difference detected is in error message, so expose that and try again
|
||||
testcase_ast.transform(new U.TreeTransformer(function(node, descend) {
|
||||
@@ -561,7 +563,9 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
testcase = code;
|
||||
differs = diff;
|
||||
} else {
|
||||
testcase_ast = U.parse(testcase);
|
||||
testcase_ast = U.parse(testcase, {
|
||||
module: minify_options.module,
|
||||
});
|
||||
}
|
||||
}
|
||||
diff_error_message = null;
|
||||
|
||||
Reference in New Issue
Block a user