Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of webpack array configs #394

Merged
merged 2 commits into from
Nov 12, 2020

Conversation

ctavan
Copy link
Contributor

@ctavan ctavan commented Nov 11, 2020

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
#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
Copy link

jsf-clabot commented Nov 11, 2020

CLA assistant check
All committers have signed the CLA.

@valscion valscion closed this Nov 11, 2020
@valscion valscion reopened this Nov 11, 2020
@valscion
Copy link
Member

This looks good to me, thank you!

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

@valscion
Copy link
Member

Can you add a changelog entry?

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
webpack-contrib#376

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

```js
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);
```
@ctavan
Copy link
Contributor Author

ctavan commented Nov 11, 2020

Can you add a changelog entry?

Done!

@valscion
Copy link
Member

Thanks!

@valscion valscion merged commit d04b767 into webpack-contrib:master Nov 12, 2020
@valscion
Copy link
Member

Released in v4.2.0 ☺️. Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants