Angular main.js file large size Angular main.js file large size angular angular

Angular main.js file large size


Split the file which is taking too much into modules and apply lazy loading


  • First of all, stop using webpack bundle analyzer because it does notgive accurate representation of your bundle space and start usingsource-map-explorer.

  • As per the Angular docs, if you import any thing outside of lazy loaded module, then it will be included in your main.js bundle. I had this issue where I was importing shared module in every module and shared module itself imported a lot of packages from node_modules which led to an increase in main.js file.