Reputation: 987
My project user angular version 7, and here is the angular.json configuration
when I build for production my main.js file is way too large nearly 12MB in size which makes my app to load the page very slowly. Nearly the initial load tooks 4 - 5 minutes
Thanks in advance
Upvotes: 11
Views: 31745
Reputation: 4093
if you was try lazyload module and it still not work.
change the tsconfig.json
module from commonjs
to es2020
and add sideEffects: false
to your package.json
and then, voila:
full explain I was talk in here https://stackoverflow.com/a/72342681/5748537
btw, you can use g-zip
on server to make it faster.
Upvotes: 1
Reputation: 93
First of all, stop using webpack bundle analyzer because it does not give accurate representation of your bundle space and start using source-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.
Upvotes: 6
Reputation: 153
Split the file which is taking too much into modules and apply lazy loading
Upvotes: 7