From e23464934962c5912e8a1dc312fd9ba9ae2a2ef3 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 30 Sep 2015 16:42:08 -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 cd372e0..2066203 100644 --- a/src/Module.js +++ b/src/Module.js @@ -547,7 +547,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 );