webpack-contrib / webpack-bundle-analyzer

Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap
MIT License
12.58k stars 488 forks source link

Fix handling of webpack array configs #394

Closed ctavan closed 3 years ago

ctavan commented 3 years ago

When trying to analyze a stats.json for a webpack bundle generated off of an array webpack.config.json webpack-bundle-analyzer was throwing:

Could't analyze webpack bundle: TypeError: Cannot read property 'assets' of undefined

This bug was probably introduced in https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/376

Example webpack config to generate a stats.json file that causes the crash:

function getConfig({ config }) {
  return {
    mode: 'production',
    entry: './src/index.js',
    performance: {
      hints: 'warning',
    },
    optimization: {
      minimize: true,
    },
    output: {
      filename: `${config}-[name].js`,
      chunkFilename: `${config}-chunk-[name].js`,
      path: `${__dirname}/`,
    },
  };
}

module.exports = [{ config: 'config-1' }, { config: 'config-2' }].map(getConfig);
jsf-clabot commented 3 years ago

CLA assistant check
All committers have signed the CLA.

valscion commented 3 years ago

This looks good to me, thank you!

I'll merge once Travis CI happens to work again.

valscion commented 3 years ago

Can you add a changelog entry?

ctavan commented 3 years ago

Can you add a changelog entry?

Done!

valscion commented 3 years ago

Thanks!

valscion commented 3 years ago

Released in v4.2.0 :relaxed:. Thank you for your contributions!