diff --git a/lib/output.js b/lib/output.js index e4987179..a3807bf7 100644 --- a/lib/output.js +++ b/lib/output.js @@ -773,6 +773,7 @@ function OutputStream(options) { || p instanceof AST_Expansion // [...(a, b)] || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {} || p instanceof AST_Yield // yield (foo, bar) + || p instanceof AST_Export // export default (foo, bar) ; }); @@ -844,7 +845,8 @@ function OutputStream(options) { PARENS(AST_Call, function(output){ var p = output.parent(), p1; - if (p instanceof AST_New && p.expression === this) + if (p instanceof AST_New && p.expression === this + || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function) return true; // workaround for Safari bug. diff --git a/test/compress/export.js b/test/compress/export.js index 783fa80a..00425c9d 100644 --- a/test/compress/export.js +++ b/test/compress/export.js @@ -280,6 +280,13 @@ export_default_anonymous_function: { expect_exact: "export default function(){foo()};" } +export_default_seq: { + input: { + export default (1, 2) + } + expect_exact: "export default(1,2);" +} + export_default_arrow: { options = { reduce_vars: true, @@ -410,7 +417,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: { @@ -444,3 +451,10 @@ export_default_anonymous_async_function_not_call: { // agrees with `acorn` and `babylon 7` expect_exact: "export default async function(){};foo;" } + +issue_2977: { + input: { + export default (function () {})(); + } + expect_exact: "export default(function(){}());" +}