score:1

Accepted answer

found an answer by michael jungo in a similar question: https://stackoverflow.com/a/44542254/4513747

a webpack bundle does not expose your exports by default, as it assumes that you're building an app and not a library (which is the far more common use of webpack). you can create a library by configuring output.library and output.librarytarget

the documentation at https://webpack.js.org/guides/author-libraries, walks you through the process of using webpack for bundling a library.

using the output in webpack.config.js as in the following, exposes the exports when bundling.

output: {
  path: path.join(__dirname, 'dist'),
  filename: '[name]/index.js',
  library: 'yourlibraryname',
  librarytarget: 'umd',
},

more information on this can be found at https://webpack.js.org/configuration/output/#output-library


Related Query

More Query from same tag