Search code examples
angularwebpack-bundle-analyzer

unable to Angular 18 with webpack-bundle-analyzer


I'm building my Angular 18 application for bundle analysis:

ng build -stats-json

The resulting stats.json has 38K lines. Then I attempt to analyze using:

webpack-bundle-analyzer <path-to-json-file>

which gives me an error:

Could't analyze webpack bundle:
TypeError: Cannot read properties of undefined (reading 'filter')

Solution

  • You're using the application builder which doesn't rely on webpack but on esbuild.

    For esbuild, you should you this analyzer: https://esbuild.github.io/analyze/

    Contrary to the webpack solution, there is dedicated package for that yet, this is only accessible via the webpage. See the dedicated issue on that topic.