04.03.2020

Angular Compiler Is Really Slow

When run 'ng serve' or 'ng serve -aot' CPU usage is upper 100% and performance is so bad. Recompiling take about 3 minutes on reload page. Environment Angular CLI: 6.1.1 Node: 10.7.0 OS: darwin x64 Angular: 6.1.0.

Animations, common, compiler, compiler-cli, core, forms. Http, language-service, platform-browser. Platform-browser-dynamic, platform-server, router Package Version - @angular-devkit/architect 0.6.8 @angular-devkit/build-angular 0.6.8 @angular-devkit/build-optimizer 0.6.8 @angular-devkit/core 0.6.8 @angular-devkit/schematics 0.7.1 @angular/cli 6.1.1 @ngtools/webpack 6.0.8 @schematics/angular 0.7.1 @schematics/update 0.7.1 rxjs 6.2.2 typescript 2.7.2 webpack 4.8.3.

Production builds are usually slower than development builds. Besides using -aot, other optimizations are also used. I do think your build time is too long though. I haven't seen other apps that have such a big difference between prod and dev build time.

Chunk asset optimization is a phase where sourcemaps are usually handled. But you have them turned off. I'm unsure of what's happening. Perhaps it's related to. Is this a public project that I can look at? You might also have a cyclic dependency perhaps. If so, could help you.

The window that I was seeing said 'Windows File Protection'. Hi Macboatmaster, Thanks again for your assistance. I'm not sure how long it usually takes to complete, but for me, it lasted about 10-12 minutes and then vanished, with nothing happening afterwards. This newer problem is likely atttributed to a power failure that occurred while the system restore was in progress. I hope that there is something that I can do to correct both of these problems. Wininet download c for mac free.

Install Angular Compiler

Note: sourcemaps are disabled in production builds by default, while css extraction is enabled by default. No luck time: 167712ms. Ng build -prod Angular CLI: 1.6.0 Node: 8.7.0 OS: win32 x64 Angular: 5.1.0 @angular/cli: 1.6.0 @angular-devkit/build-optimizer: 0.0.35 @angular-devkit/core: 0.0.22 @angular-devkit/schematics: 0.0.41 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.9.0 @schematics/angular: 0.1.10 @schematics/schematics: 0.0.10 typescript-string-enums: 0.3.5 typescript: 2.6.2 webpack-dev-middleware: 1.12.2 webpack-dev-server: 2.9.7 webpack-merge: 4.1.1 webpack-sources: 1.1.0 webpack: 3.10.0. I had a try at 's comment on a new project and saw no discernable difference on a prod build (11544ms vs 11724ms). Something I know can have a big difference is the version of uglify we use, which should be improved.

Increasing the memory limit like does is not a hack, and something you should expect to do at some point. Node processes have a default memory limit of about 1.7gigs. When a node process starts getting close to the memory limit it needs to spend more and more time doing garbage collection to free up memory, which in turn makes it run more slowly.

Bigger projects will use up more memory than smaller projects so at some point a project will hit the memory limit. I personally use a npm script for this: 'ng-high-memory': 'node -maxoldspacesize=8000./nodemodules/@angular/cli/bin/ng', It's hard to act on many of these reports since there is no objective reproduction that we can follow. It's not that we don't believe that builds can be slow. But builds can be slow for many reasons. It's exceedingly likely that the projects that are seeing the most dramatic build times are suffering from some odd problem somewhere in the pipeline that is not a general problem, and for those we really need to reproduce it to fix it. General performance improvements are of course always helpful, and we try to do them as much as possible.

Angular Compiler Options

But the absolute best way of getting us to fix issues, especially hard to fix ones, is to offer concrete repros. With these: @angular-devkit/architect 0.8.1 @angular-devkit/build-angular 0.8.1 @angular-devkit/build-optimizer 0.8.1 @angular-devkit/build-webpack 0.8.1 @angular-devkit/core 0.8.1 @angular-devkit/schematics 0.8.1 @angular/cli 6.2.1 @ngtools/webpack 6.2.1 @schematics/angular 0.8.1 @schematics/update 0.8.1 rxjs 6.3.2 typescript 2.9.2 webpack 4.18.0 Running node -maxoldspacesize=12000./nodemodules/@angular/cli/bin/ng build -prod -source-map I'm now down to Time: 470558ms (8 min).

Much better and tolerable. Seems like maxoldspacesize should be configurable within tsconfig.app.json. All of the OSX developers on our team were experiencing very high CPU usage, and very slow ng build and ng serve times (3-8 minutes for initial build and/or recompile).

Really

Bumping node to version 10.x via nvm, removing nodemodules from the project, and reinstalling with an npm install dropped initial build time to about 30 seconds and recompile to about 12 seconds. This is on rather large, angular 6 application Saved my day.

I confirm that on os x with nodejs v10.11.0 I can see a significant improvement. Our build with these parameters (ng build -prod -aot=false -optimization=true -sourceMap=false -buildOptimizer=false) creates 71 bundles in just over 2 minutes with a total size of 11MB for all bundles. Now we turn the -aot flag to true and what happens?? The build takes about 43 minutes, comes up with 84 bundles and has a total size of 22MB???? Isn't AOT supposed to minimize the size by excluding what is not being used? But instead it takes 41 minutes to create twice as many code? What's going on here?

Aot precompiles the HTML templates into straight forward js files which keep the view updated. These are larger than the templates themselves, so there's a point where the combined size surpasses the size of the runtime compiler. It saves time at runtime because it's a step done in advance. But you pointed out the bundles are so much bigger you consider the non-aot is faster to startup.

Which may be true for uncached assets, plus the difference in parsing a larger file. I build into a single bundle, so your experience with so many bundles ought to be different.

Angular compiler options

I suggest you compare these options on different devices as well. Mobile and desktop, and keep the one that perform better. Since recent versions I can't use appveyor CI no more since the build runs more than an hour. I've updated to latest version (from 6 to 7) hoping it would improve but it just got worse. I've tried to use build-optimizer=false but the build fails (What??).

I'd love for some insights, I'm desperate. Code can be found here: Appveyour build can be found here: The relevant branch which I'm currently working on is called openlayers. Please let me know if you need anything else. Production build used to run for about 10 minutes in angular version 4-5 I think.

I've sent a heart breaking mail to appveyor and asked them to increase the timeout, hope they would help out, but I would really like my build to take less time, this is not a huge app. Thanks for the super quick response!

As can be seen here on the openlayers branch the devkit version is 0.11: I'll try to migrate all my css file to scss, although I have a generated one from icomoon which I don't fancy migrating every time I change it, but if it will reduce the build time I'll give it a go. But the build only took a little over a minute for me.

Angular compiler is really slow cooker

Did you build it with -prod? In any case, the appveyor servers are limited on resources and it is taking a very long time there.

They were kind enough to extend the timeout to 90 minutes just now, I hope it will be enough.