35

I would like to learn how my angular code is bundled and to which chunk files. Therefore I'm using "Webpack bundle analyzer". For some modules it's written in the report as: router.js + "12 Modules".

How can I determine the contents of the 12 Modules? I clicked on the line and it didn't help.

webpack-bundle-analyzer output

olore
  • 4,687
  • 3
  • 28
  • 40
Omtechguy
  • 3,321
  • 7
  • 37
  • 71

4 Answers4

64

In the webpack bundle analyzer UI, there is a checkbox where you can show the contents of concatenated modules. If you check that box, you will see the contents.

Here is what the UI looks like, where you can toggle the setting: enter image description here

Here is what it looks like without the box checked: enter image description here

Here is what it looks like WITH the box checked: enter image description here

frosty
  • 21,036
  • 7
  • 52
  • 74
3

Sounds like you are using the ModuleConcatenationPlugin, try commenting it out. It's one of the plugins that can obscure this. Here are more details and the defect logged.

olore
  • 4,687
  • 3
  • 28
  • 40
1

Webpack now supports turning off module concatenation:

// webpack.config.js

module.exports = {
  //...
  optimization: {
    concatenateModules: false,
  },
};

https://webpack.js.org/configuration/optimization/#optimizationconcatenatemodules

frodo2975
  • 10,340
  • 3
  • 34
  • 41
0

Similar to what Philipp Feigl suggested here, I modified my package.json of my Angular 7 cli project.

My application is called playpen, so adjust the location of the stats.json file on your bundle-report target.

So dist/playpen/stats.json should be dist/{YOURAPP}/stats.json

{
  "name": "playpen",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "bundle-report": "ng build --prod --stats-json --build-optimizer=false --vendor-chunk=true --named-chunks=true --output-hashing=media && webpack-bundle-analyzer dist/playpen/stats.json"
  },
rjdkolb
  • 10,377
  • 11
  • 69
  • 89