@@ -561,8 +561,8 @@ merge(Compressor.prototype, {
|
|||||||
return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
|
return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
|
||||||
});
|
});
|
||||||
|
|
||||||
function is_func_expr(node) {
|
function is_func_expr(node, traditional) {
|
||||||
return node instanceof AST_Arrow || node instanceof AST_Function;
|
return node instanceof AST_Function || !traditional && node instanceof AST_Arrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_lhs_read_only(lhs) {
|
function is_lhs_read_only(lhs) {
|
||||||
@@ -706,9 +706,9 @@ merge(Compressor.prototype, {
|
|||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
||||||
function is_iife_call(node) {
|
function is_iife_call(node, traditional) {
|
||||||
if (node instanceof AST_Call && !(node instanceof AST_New)) {
|
if (node instanceof AST_Call && !(node instanceof AST_New)) {
|
||||||
return is_func_expr(node.expression) || is_iife_call(node.expression);
|
return is_func_expr(node.expression, traditional) || is_iife_call(node.expression);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3452,7 +3452,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
if (compressor.option("negate_iife")
|
if (compressor.option("negate_iife")
|
||||||
&& compressor.parent() instanceof AST_SimpleStatement
|
&& compressor.parent() instanceof AST_SimpleStatement
|
||||||
&& is_iife_call(self)) {
|
&& is_iife_call(self, true)) {
|
||||||
return self.negate(compressor, true);
|
return self.negate(compressor, true);
|
||||||
}
|
}
|
||||||
var ev = self.evaluate(compressor);
|
var ev = self.evaluate(compressor);
|
||||||
|
|||||||
@@ -1045,11 +1045,11 @@ function OutputStream(options) {
|
|||||||
var needs_parens = parent instanceof AST_Binary ||
|
var needs_parens = parent instanceof AST_Binary ||
|
||||||
parent instanceof AST_Unary ||
|
parent instanceof AST_Unary ||
|
||||||
(parent instanceof AST_Call && self === parent.expression);
|
(parent instanceof AST_Call && self === parent.expression);
|
||||||
|
if (needs_parens) { output.print("(") }
|
||||||
if (self.async) {
|
if (self.async) {
|
||||||
output.print("async");
|
output.print("async");
|
||||||
output.space();
|
output.space();
|
||||||
}
|
}
|
||||||
if (needs_parens) { output.print("(") }
|
|
||||||
if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
|
if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
|
||||||
self.argnames[0].print(output);
|
self.argnames[0].print(output);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -268,3 +268,27 @@ async_arrow_wait: {
|
|||||||
}
|
}
|
||||||
expect_exact: "var a=async(x,y)=>await x(y);"
|
expect_exact: "var a=async(x,y)=>await x(y);"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async_arrow_iife: {
|
||||||
|
input: {
|
||||||
|
(async () => {
|
||||||
|
await fetch({});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_exact: "(async()=>{await fetch({})})();"
|
||||||
|
}
|
||||||
|
|
||||||
|
async_arrow_iife_negate_iife: {
|
||||||
|
options = {
|
||||||
|
negate_iife: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async () => {
|
||||||
|
await fetch();
|
||||||
|
})();
|
||||||
|
(() => {
|
||||||
|
plain();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_exact: "(async()=>{await fetch()})();(()=>{plain()})();"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user