babel-plugin-flow-react-proptypes icon indicating copy to clipboard operation
babel-plugin-flow-react-proptypes copied to clipboard

named exports not functioning with `modules: false` in webpack

Open apkrasny opened this issue 7 years ago • 2 comments

When using babel + webpack with modules: false exports is not defined. This is because webpack generates a module wrapper with a signature of (function(module, __webpack_exports__, __webpack_require__) {. conditionalExportsAst check is always false and named exports don't function as expected.

Configuring modules back to commonjs resolves the issue but it seems as though this should be supported.

webpack reference

apkrasny avatar May 22 '17 19:05 apkrasny

Thanks for the report. What would the expected behavior be here? What code should we generate?

brigand avatar May 22 '17 19:05 brigand

Ideally all imports/exports would be done using ES2015 modules, and these would be handled by webpack or transformed by babel further down the pipeline. I am not familiar with babel and don't know if it will traverse generated code.

Alternatively, provide an option between CJS or ES2015 so that the correct code will be emitted.

apkrasny avatar May 22 '17 20:05 apkrasny