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

Confusing error message if stats.children is disabled in webpack config #35

Open
gustavohenke opened this issue Feb 3, 2017 · 2 comments
Labels

Comments

@gustavohenke
Copy link

Hi!
I tried running webpack-bundle-size-analyzer against the output generated by my app for the first after some iterations, and was surprised by the following error:

λ webpack --json --verbose | webpack-bundle-size-analyzer
C:\Users\gustavo\AppData\Roaming\npm\node_modules\webpack-bundle-size-analyzer\build\src\size_tree.js:136
        return stats.children.map(bundleSizeTree);
                             ^

TypeError: Cannot read property 'map' of undefined
    at Object.dependencySizeTree (C:\Users\gustavo\AppData\Roaming\npm\node_modules\webpack-bundle-size-analyzer\build\src\size_tree.js:136:30)
    at printStats (C:\Users\gustavo\AppData\Roaming\npm\node_modules\webpack-bundle-size-analyzer\build\src\cli.js:14:30)
    at Socket.<anonymous> (C:\Users\gustavo\AppData\Roaming\npm\node_modules\webpack-bundle-size-analyzer\build\src\cli.js:43:50)
    ...

One change I made was to hide most stats from the webpack logs with the stats key my webpack.config.js:

stats: {
    assets: true,
    children: false,
    chunks: false,
    errors: true,
    errorDetails: true,
    modules: false,
    timings: true,
    colors: true
}

Obviously this was the cause of the error above.
The only thing I found to work is to remove these. I haven't tried any combination of webpack CLI flags apart from --verbose --json (which didn't work).

It would be nice to document this problem and how to solve it, so others don't get into this trap as well.
And if you know about a more elegant way around this, let me know!

@robertknight robertknight changed the title webpack --json may not be enough Confusing error message if stats.children is disabled in webpack config Feb 3, 2017
@robertknight
Copy link
Owner

Thanks for the report. I didn't know that it was possible to configure webpack in such a way that this information would be missing from the JSON output. It shouldn't be too difficult to to spit out a more helpful error message.

@gustavohenke
Copy link
Author

And thank you for making the title of this issue clearer as well 😊

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

No branches or pull requests

2 participants