Rebuild extremely slow
-
OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Windows 10
-
Versions. Please run
ng --version. If there's nothing outputted, please run in a Terminal:node --versionand paste the result here: angular-cli: 1.0.0-beta.11-webpack.8 node: 6.3.0 os: win32 x64 -
Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc. app created with 1.0.0-beta.11-webpack.2 and later on upgraded to 1.0.0-beta.11-webpack.8 with appropriate changes.
-
The log given by the failure. Normally this include a stack trace and some more information. The slow behavious is observed when upgraded from 1.0.0-beta.11-webpack.2 to 1.0.0-beta.11-webpack.8
-
Mention any other details that might be useful. Slow behavious reproduceable in following repo: https://github.com/asadsahi/ng2fb-bootstrap
I have experience this on two operating systems, windows 7 and windows 10. Has anyone else experieced this? For me rebuilds are dramatically slow, taking roughly 7-8 seconds which on same machine with cli version webpack.2 was taking rougly 2-3 seconds.
I think there are too many special cases to allow an automatic dll build to be ultimately reliable (e.g., including all depth zero packages would include packages that are not used in code; which could be benign or fatal).
Realistically, is it even necessary? The dll build is only really useful in development scenarios (ng serve / ng build --watch) as the vendor bundle covers production builds. So providing maximum configurability may not be needed. Covering the known large code size offenders (i.e., the angular libraries and their dependencies) should hopefully provide a noticeable performance improvement with minimal additional complexity. Further, the configurability can always be expanded upon in the future.
My idea was to use a similar strategy to the one we already use for the vendor chunk to determine DLL packages. Basically all top-level modules requested by the the main (and lazy loaded) chunks that are located in node_modules.
It might be enough initially to just hardcode the angular packages though.
At the moment I'm still blocked by some weird interactions between the AoTPlugin and DLLPlugin. Builds seem to break as soon as an angular lib is factored out into the DLL bundle.
Another update: moving to [email protected] (https://github.com/angular/angular-cli/pull/3786) seems to have had roughly a 30% performance (1.69s to 1.3s) increase in rebuilds.
+1 for improving the speed at least for scss and ts compilation. Compared to Gulp it takes 10sec on my machine compiling Bootstrap SCSS instead of less than 500ms. Smiliar results on ts files.
@MickL are you seeing similar results to my comment? https://github.com/angular/angular-cli/issues/1980#issuecomment-264649140
I think my comment about saving SCSS files went unnoticed and it's insanely random :)
@intellix @MickL I haven't looked at SCSS much yet but will.
Does angular-cli offer live-reload feature?
If so, what makes the difference as compared to react?
My react project applies code changes instantly whether it is js or styles...
I assume it's using webpack-hot-middleware.
I'm going to use this starter kit, wondering how it affects development speed.
@RumenTech modifying scss files trigger recompilation. Cold start of my project is 25 seconds, while small change in scss file takes ~2-4 seconds BUT app is being refreshed.
This is what I'm dealing with on one of my larger projects that uses .scss, and ng build -prod -aot
Time: 678933ms // 11 minutes
I guess TypeScript compiler is okay. But SCSS is way too slow. As far as i know Angular CLI is using libsass which is the best choice. But lets compare a regular Boostrap compile to gulp-sass (also using libsass) in combination with gulp-sourcemaps.
On my machine i get following results in average: Gulp: 250ms Angular CLI: 4500ms
Also we have a full page reload instead of just reloading the styles. But this is not part of this issue i guess.
Steps to reproduce:
- ng new scss-project --style=scss
- npm install [email protected] --save-dev
- Add import to /src/app/style.scss:
@import '../node_modules/bootstrap/scss/bootstrap'; - ng serve
- Try adding something into styles.scss, for example: h1 { color:red; }
- Reload takes 4-5s on my machine
i think there might be a way how to modify SASS files for GLOBAL style without triggering the recompilation. .. I hoped Lazy Styles was it, but it triggers recompilation too :-/
The sass recompilation with my gulp script takes 100-150ms, but the recompiled style.css triggers recompilation which takes 25sec.. + 5sec reload. So every change in global style takes 30sec to take in place.
In my env (ng beta-24), 8GB RAM, SSD, Ubuntu VirtualBox on Windows 10 it takes also a minute to rebuild. Does anyone know a good article describing an alternative build/serve process, while maintaining the structure provided by angular-cli, so I could come back when the issue is resolved ? Thanks so much.
@ralf100 i think the angular-cli is mainly only about to have entry point, src folder, assets folder and angular-cli so you can have some better starte pack (i strongly suggest you that one from QDOUBLE on github) and still use Angular-cli for scaffolding, then you shoudl be able to switch back.
Time: 15111ms
Around 15s for a project I just recently started with, so not too big yet. I'm on Windows7, npm v.4.1.1, node v6.9.2 [email protected]
https://github.com/angular/angular-cli/pull/3943 should help with the rebuilds of global CSS.
As mentioned by @filipesilva, the performance was nicely improved with the upgrade to Webpack 2 rc3 (rc4 released today, by the way). However, it is still not as good as it should be, imho. So I decided to do some quick profiling with node-nightly and the chrome dev tools. I haven't had the time to really dig deep into it, but here are some screenshots of the profile I ran during a 3rd or 4th rebuild, without any file changes.
We can see that the great majority of the time is spent by typescript (and, up to a point, by Webpack) trying to figure out if a file or folder exists in order to properly resolve modules. This makes me wonder if it wouldn't be possible to have TS and Webpack cache all the files and their locations (relative included) and only re-check them when there is a notification from the filesystem saying that a certain file has actually changed.
Say file A refers to file B and C. If only file A was changed in the filesystem, can check the imports and, if they didn't change, we know that file B and C exist, we know exactly where they are and ideally we even have their contents in memory somewhere. If, say, only the reference to file B changed, then we can go look only for file B. And so on.
It may actually be the case that the normal watch mode of TSC actually does something similar to what I described above, even though I haven't had the time to check. It is much faster than via webpack. However, I guess the webpack loader has a harder time because it is just calling TS to compile a certain file or set of files.
Anyone has any other insights? Maybe this could be something to bring up directly with Webpack and Typescript. What do you think?
@hccampos awesome deduction, what does it look like with CSS preproccesors?
Hey @hccampos, thanks for those! Very helpful.
So I feel you're running a ng build, correct? I ran a ng serve (with https://github.com/angular/angular-cli/pull/3961 locally) and modified a file a bunch of times, and I got a very different graph:

Here's the cpuprofile file: test.cpuprofile.zip
@TheLarkInn seems like the above a lot of the time is lost in ReplaceSource and HarmonyModulesHelpers.
Sorry the screen above is sorted by Total Time. Here's sorted by Self Time:

Seems like Typescript does a lot of checks. Let's see if we can help there.
@hansl @hccampos compilerOptions.isolatedModules is the one flag that can impact rebuild times in a huge way. I'm using custom gulp tasks for building (on top of CLI project) and if I set "isolatedModules": false rebuild times for just touching one file are 3.39s, 3.33s, 3.29s. with "isolatedModules": true I get 186ms, 73ms, 82ms. I'm not familiar with inner workings of webpack, so I'm not sure where/how this would affect other stuff, but I hope it helps (;