parenthesise exported iifes correctly
This commit is contained in:
parent
569757d14d
commit
402bbda1d1
|
|
@ -1106,6 +1106,20 @@ function OutputStream(options) {
|
|||
self._do_print(output);
|
||||
});
|
||||
|
||||
DEFPRINT(AST_Function, function(self, output) {
|
||||
var parent = output.parent();
|
||||
var grandparent = output.parent(1);
|
||||
var is_exported_iife = parent instanceof AST_Call && parent.expression == self &&
|
||||
grandparent instanceof AST_Export && grandparent.is_default;
|
||||
if (is_exported_iife) {
|
||||
output.with_parens(function() {
|
||||
self._do_print(output);
|
||||
});
|
||||
} else {
|
||||
self._do_print(output);
|
||||
}
|
||||
});
|
||||
|
||||
DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
|
||||
self.prefix.print(output);
|
||||
self.template_string.print(output);
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ export_default_anonymous_function_not_call: {
|
|||
export default function(){}(foo);
|
||||
}
|
||||
// FIXME: should be `export default function(){};foo;`
|
||||
expect_exact: "export default function(){}(foo);"
|
||||
expect_exact: "export default(function(){})(foo);"
|
||||
}
|
||||
|
||||
export_default_anonymous_generator_not_call: {
|
||||
|
|
|
|||
7
test/compress/issue-2977.js
Normal file
7
test/compress/issue-2977.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
issue_2977: {
|
||||
input: {
|
||||
export default (function () {})();
|
||||
}
|
||||
expect_exact: "export default(function(){})();"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user