In my case, I have the same problem when using babel-loader with Babel 6. Even when I installed
"libraryTarget": "commonjs2"
I have the results:
const foo = require('some-module'); console.log(foo) // is {} const bar = require('some-module').default; console.log(bar) // is default export of 'some-module'
If you want to:
const foo = require('some-module'); console.log(foo) // is default export of 'some-module'
You can use: babel-plugin-add-module-exports
UPDATE:
Webpack authors do not recommend using babel-plugin for this.
Webpack 3 has an output.libraryExport option (you donβt have any detailed documents right now)
I tried like this
output.libraryExport: 'default'
and this fixed the problem.
source share