We have an angular 5 project which has a problem with size. On load of the app, when there isn't much of anything, we have 95MB in memory.
I'm trying to analyze it and use webpack-bundle-analyzer
.
I've read that adding new webpack.optimize.ModuleConcatenationPlugin()
into webpack.config
should help, so I did and it helped (from 95 to 76MB).
But when I run build with stats after that npm run build:stats > stats.json
("build:stats": "webpack --profile --json --config webpack.config.buildserver.js"
) I get this message
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Before adding the plugin, the stats.json
file had around 390 000 lines of json object.
I found that there is a memory flag for node scripts --max_new_space_size
but I can't find anything similar for webpack script.
I'm not sure what to look for, could anyone help please?
It's a known bug, you can check this issue for more details and also try to install this npm package and run before you build and after npm install.