I have a simple library like so:
export const foo = () => {
console.log("Hello")
}
I am trying to use Webpack to bundle it to CommonJS like so:
module.exports.foo = () => {
console.log("Hello")
}
My webpack config is simple:
module.exports = {
entry: {
index: "./src-test"
},
output: {
filename: "[name]-bundle.cjs.js",
libraryTarget: "commonjs2"
}
}
However, it's getting bundled under the default namespace like so:
module.exports = function (e) {
// ...
Why is this happening and how can I use named exports?