diff --git a/src/transform.js b/src/transform.js index 9f731c5..88238d0 100644 --- a/src/transform.js +++ b/src/transform.js @@ -109,7 +109,7 @@ export default function transform ( code, id, isEntry, ignoreGlobal, customNamed // we're dealing with `module.exports = ...` or `[module.]exports.foo = ...` – // if this isn't top-level, we'll need to wrap the module - if ( programDepth > 3 ) shouldWrap = true; + if ( programDepth > 3 || /^Function/.test( node.right.type )) shouldWrap = true; node.left._skip = true; diff --git a/test/form/optimised-default-export-function/output.js b/test/form/optimised-default-export-function/output.js index bfb9a41..c9d5d01 100644 --- a/test/form/optimised-default-export-function/output.js +++ b/test/form/optimised-default-export-function/output.js @@ -1,4 +1,8 @@ -var input = function foo () {}; +import * as commonjsHelpers from 'commonjsHelpers'; + +var input = commonjsHelpers.createCommonjsModule(function (module) { +module.exports = function foo () {}; +}); export default input; export { input as __moduleExports };