angular-cli: ng serve recompile time very slow

🐞 Bug report

Command (mark with an x)

- [ ] serve

Is this a regression?

Yes, the previous version in which this bug was not present was: ....

Description

A clear and concise description of the problem...

ng serve recompile time very slow. It spend about 10s to recompile althought I only change one space on css ~~

🔬 Minimal Reproduction

🔥 Exception or Error





🌍 Your Environment






Angular CLI: 8.3.3
Node: 10.16.3
OS: win32 x64
Angular: 8.2.5
... animations, common, compiler, compiler-cli, core, forms   
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------   
@angular-devkit/architect         0.803.3
@angular-devkit/build-angular     0.803.3
@angular-devkit/build-optimizer   0.803.3
@angular-devkit/build-webpack     0.803.3
@angular-devkit/core              8.3.3
@angular-devkit/schematics        8.3.3
@angular/cli                      8.3.3
@ngtools/webpack                  8.3.3
@schematics/angular               8.3.3
@schematics/update                0.803.3
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

Anything else relevant?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

I’m unable to replicate the behavior you are seeing. First change below is a TS file, second a CSS file, and third an HTML file.

chunk {main} main.js, main.js.map (main) 160 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 263 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 11.5 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 4.44 MB [initial] [rendered]
Date: 2019-10-04T01:30:12.616Z - Hash: 6f221bb7fb4e9a120bb3 - Time: 7640ms
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
ℹ 「wdm」: Compiled successfully.
ℹ 「wdm」: Compiling...

Date: 2019-10-04T01:30:21.546Z - Hash: 6f221bb7fb4e9a120bb3
5 unchanged chunks

Time: 615ms
ℹ 「wdm」: Compiled successfully.
ℹ 「wdm」: Compiling...

Date: 2019-10-04T01:30:36.442Z - Hash: 7914e96ba922047d0d49
4 unchanged chunks
chunk {main} main.js, main.js.map (main) 160 kB [initial] [rendered]
Time: 573ms
ℹ 「wdm」: Compiled successfully.
ℹ 「wdm」: Compiling...

Date: 2019-10-04T01:30:48.431Z - Hash: f8f4000a17dce840bd77
4 unchanged chunks
chunk {main} main.js, main.js.map (main) 160 kB [initial] [rendered]
Time: 634ms
ℹ 「wdm」: Compiled successfully.

I’m sorry, but we can’t reproduce the problem following the instructions you provided. Remember that we have a large number of issues to resolve, and have only a limited amount of time to reproduce your issue. Short, explicit instructions make it much more likely we’ll be able to reproduce the problem so we can fix it.

If the problem persists, please open a new issue following our submission guidelines.

A good way to make a minimal repro is to create a new app via ng new repro-app and add the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@sodepr, you might also have an anti-virus that is scanning files when being accessed and is slowing the compilation.

I tried your reproduction and here’s the timings

chunk {main} main.js, main.js.map (main) 156 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 263 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 11.4 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 4.44 MB [initial] [rendered]
Date: 2019-10-04T15:14:29.033Z - Hash: 608727f408d623de243c - Time: 12199ms
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
ℹ 「wdm」: Compiled successfully.
ℹ 「wdm」: Compiling...

Date: 2019-10-04T15:14:38.354Z - Hash: bc598b1bc970015bfcf4
4 unchanged chunks
chunk {styles} styles.js, styles.js.map (styles) 11.4 kB [initial] [rendered]
Time: 877ms
ℹ 「wdm」: Compiled successfully.

Also, having the entire fontawesome as part of the your assets doesn’t seem right as it includes files that will never be used by your application and are copied redundantly.

There’s still over 1500 files and 22 MB in the assets folder. This is going to take some time to copy.

Looks like the large amount of assets is causing the slowdown. Can you remove non-essential files from the assets directory?

Hi @sodepr. thanks for opening the issue. Is there a way you can share your project or a reproduction so that we can take a look at?

You can read here why this is needed.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.