diff --git a/src/Declaration.js b/src/Declaration.js index ef10b7f..e1d5ef9 100644 --- a/src/Declaration.js +++ b/src/Declaration.js @@ -110,9 +110,15 @@ export class SyntheticDefaultDeclaration { return this.original.run( strongDependencies ); } - if ( /FunctionExpression/.test( this.node.declaration.type ) ) { - return run( this.node.declaration.body, this.statement.scope, this.statement, strongDependencies, false ); + let declaration = this.node.declaration; + while ( declaration.type === 'ParenthesizedExpression' ) declaration = declaration.expression; + + if ( /FunctionExpression/.test( declaration.type ) ) { + return run( declaration.body, this.statement.scope, this.statement, strongDependencies, false ); } + + // otherwise assume the worst + return true; } use () { diff --git a/test/function/default-exports-in-parens/_config.js b/test/function/default-exports-in-parens/_config.js new file mode 100644 index 0000000..1855ab2 --- /dev/null +++ b/test/function/default-exports-in-parens/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'handles default function exports wrapped in parens' +}; diff --git a/test/function/default-exports-in-parens/foo.js b/test/function/default-exports-in-parens/foo.js new file mode 100644 index 0000000..b052a6b --- /dev/null +++ b/test/function/default-exports-in-parens/foo.js @@ -0,0 +1,3 @@ +export default (function () { + global.answer = 42; +}); diff --git a/test/function/default-exports-in-parens/main.js b/test/function/default-exports-in-parens/main.js new file mode 100644 index 0000000..9511c19 --- /dev/null +++ b/test/function/default-exports-in-parens/main.js @@ -0,0 +1,3 @@ +import foo from './foo.js'; +foo(); +assert.equal( global.answer, 42 );