Output ES Modules with Webpack


I was having trouble finding exactly how to output ES Modules with Webpack 5. Here’s the Webpack configuration I used:

{
  ...config,
  experiments: {
   futureDefaults: true,
   outputModule: true,
  },
  output: {
   ...config.output,
   module: true,
   chunkFormat: 'module',
  },
 }