1

My team has recently switched to Angular 4 from Angular 2. Also we switched Webpack from version 1.x to 3.8.1. The compilation time became ridiculously slow (around 50 minutes). Recompilation on small changes takes seconds though.

Overall size of the frontend is 300MB. Initial assumption was that problem happens because of too many libraries in node_modules. But after removing over 90% of our project files (node_modules are not touched) the compilation time became 2 minutes and overall directory size is 280MB. Where 5 MB is what left of our project files and the rest 275MB is the node_modules folder. So the problem should be somewhere in configs or in the way how we write the code. Did anyone have this problem before? What could possibly cause such problems?

Unfortunately, I am not allowed to share any code. But will very appreciate if anyone has any advice.

Edster
  • 143
  • 2
  • 13
  • 1
    It doesn't matter how big your node_modules is. It matters which packages contribute to the bundle and how much. It doesn't matter if a package is 50mb if it contributes only 20kb. – Estus Flask Feb 07 '18 at 16:41
  • We have all these modules downloaded and used in the past. Right now our project almost does not use any external sources. But compilation time is still 2 minutes for 5MB of project files. – Edster Feb 07 '18 at 16:45
  • You didn't specify the most important part, what compilation type is used. This number looks plausible for AOT. – Estus Flask Feb 07 '18 at 16:58
  • Not sure what do you mean by compilation type. But before we used just npm (everything was fine) and now we have migrated to yarn. We are using 'yarn start' to compile project. Where 'start' is defined as ""webpack-dev-server --color --progress" in package.json. – Edster Feb 07 '18 at 17:08
  • Compilation type, i.e. JIT or AOT. It's crucial for build speed. It depends on project configuration, not on the command you're running. – Estus Flask Feb 07 '18 at 17:10
  • We are using JIT. I just read an article: https://scotch.io/@kashyapmukkamala/jit-vs-aot-in-angular2-and-how-to-use-it Do you think it is worth trying to switch to AOT and see if makes any difference? – Edster Feb 07 '18 at 17:19
  • Yes, I'd suggest to do that. At least this can give some clues. I would expect 1-2 minutes for AOT, but for JIT this is really going too far. – Estus Flask Feb 07 '18 at 17:23
  • Possible duplicate of [Huge number of files generated for every Angular project](https://stackoverflow.com/questions/38718690/huge-number-of-files-generated-for-every-angular-project) – Zze Feb 08 '18 at 02:45

1 Answers1

1

AOT is almost guaranteed to take longer to build than JIT.

Things that help my performance

olore
  • 4,687
  • 3
  • 28
  • 40