From 940daa4f5b5a9b61ccf757cd9cc038f707dbc4e6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 30 Sep 2015 16:45:20 -0400 Subject: [PATCH] handle parenthesised default exports (#136) --- src/Module.js | 3 ++- test/function/parenthesised-default-export/_config.js | 3 +++ test/function/parenthesised-default-export/main.js | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/function/parenthesised-default-export/_config.js create mode 100644 test/function/parenthesised-default-export/main.js diff --git a/src/Module.js b/src/Module.js index 4be76d9..1b2970e 100644 --- a/src/Module.js +++ b/src/Module.js @@ -495,7 +495,8 @@ export default class Module { ast = parse( this.source, { ecmaVersion: 6, sourceType: 'module', - onComment: ( block, text, start, end ) => this.comments.push({ block, text, start, end }) + onComment: ( block, text, start, end ) => this.comments.push({ block, text, start, end }), + preserveParens: true }); } catch ( err ) { err.code = 'PARSE_ERROR'; diff --git a/test/function/parenthesised-default-export/_config.js b/test/function/parenthesised-default-export/_config.js new file mode 100644 index 0000000..65de328 --- /dev/null +++ b/test/function/parenthesised-default-export/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'allows default exports to be enclosed in parentheses' +}; diff --git a/test/function/parenthesised-default-export/main.js b/test/function/parenthesised-default-export/main.js new file mode 100644 index 0000000..39430e6 --- /dev/null +++ b/test/function/parenthesised-default-export/main.js @@ -0,0 +1 @@ +export default ( 42 );