diff options
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/output.js b/lib/output.js index 49164359..bebcd7fd 100644 --- a/lib/output.js +++ b/lib/output.js @@ -664,7 +664,9 @@ function OutputStream(options) { function needs_parens_function(output) { if (!output.has_parens() && first_in_statement(output)) return true; var p = output.parent(); - // export default (function() {})() + // export default (function foo() {}); + if (this.name && p instanceof AST_ExportDefault) return true; + // export default (function() {})(foo); if (p && p.TYPE == "Call" && output.parent(1) instanceof AST_ExportDefault) return true; if (output.option("webkit") && p instanceof AST_PropAccess && p.expression === this) return true; if (output.option("wrap_iife") && p instanceof AST_Call && p.expression === this) return true; @@ -725,6 +727,8 @@ function OutputStream(options) { // { [(1, 2)]: foo } = bar // { 1: (2, foo) } = bar || p instanceof AST_DestructuredKeyVal + // export default (foo, bar) + || p instanceof AST_ExportDefault // for (foo of (bar, baz)); || p instanceof AST_ForOf // { [(1, 2)]: 3 }[2] ---> 3 @@ -1032,9 +1036,16 @@ function OutputStream(options) { output.space(); output.print("default"); output.space(); - this.body.print(output); - if (this.body instanceof AST_Class) return; - if (this.body instanceof AST_Lambda && !is_arrow(this.body)) return; + var body = this.body; + body.print(output); + if (body instanceof AST_ClassExpression) { + if (!body.name) return; + } + if (body instanceof AST_DefClass) return; + if (body instanceof AST_LambdaDefinition) return; + if (body instanceof AST_LambdaExpression) { + if (!body.name && !is_arrow(body)) return; + } output.semicolon(); }); DEFPRINT(AST_ExportForeign, function(output) { |