angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

After upgrading to Angular 8 , compile time increased 3 times.

Open alialtun14 opened this issue 7 years ago • 26 comments

I upgraded my project to Angular 8 version. While upgrading process, I haven't met any error. But the compile time increased 3 times without any error.

Last Compile Before Angular 8  (with Angular 7.2)
Time: 1382.536ms -> main.cf29a89468d732f3f363.js (main) 12.4 MB 

First Compile After Upgrading to Angular 8
Time: 6379.317ms -> main.da4147c72278bc767ee4.js (main) 12.3 MB 

Second Compile After Upgrading to Angular 8 and After restart PC 
Time: 3147.254ms -> main.da4147c72278bc767ee4.js (main) 12.3 MB

tsconfig.json

{
 "compileOnSave": false,
 "compilerOptions": {
    "baseUrl": "",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "mapRoot": "./",
    "moduleResolution": "node",
    "outDir": "../__dist_cli",
    "sourceMap": true, 
    "target": "es5 ", 
    "module": "es2015",
    "lib": [
        "es2016",
        "dom"
    ],
    "typeRoots": [
        "node_modules/@types",
        "typings/custom"
    ]
}

package.josn

   ....
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.0.0",
    "@angular/cdk": "^8.0.0",
    "@angular/common": "^8.0.0",
    "@angular/core": "^8.0.0",
    "@angular/flex-layout": "^8.0.0-beta.26",
    "@angular/forms": "^8.0.0",
    "@angular/material": "^8.0.0",
    "@angular/platform-browser": "^8.0.0",
    "@angular/platform-browser-dynamic": "^8.0.0",
    "@angular/router": "^8.0.0",
    "core-js": "^2.5.4",
    "font-awesome": "^4.7.0",
    "intl": "^1.2.5",
    "rxjs": "^6.5.2",
    "tar": "^4.4.8",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.800.0",
    "@angular-devkit/build-optimizer": "^0.800.0",
    "@angular/cli": "^8.0.0",
    "@angular/compiler": "^8.0.0",
    "@angular/compiler-cli": "^8.0.0",
    "@types/angular": "^1.6.54",
    "@types/angular-route": "^1.3.5",
    "@types/quill": "^2.0.2",
    "hammerjs": "^2.0.8",
    "quill": "^1.3.6",
    "typescript": "^3.4.5"
  }
}
Angular CLI: 8.0.0
Node: 12.3.1
OS: win32 x64
Angular: 8.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, material, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0
@angular-devkit/build-angular     0.800.0
@angular-devkit/build-optimizer   0.800.0
@angular-devkit/build-webpack     0.800.0
@angular-devkit/core              8.0.0
@angular-devkit/schematics        8.0.0
@angular/flex-layout              8.0.0-beta.26
@ngtools/webpack                  8.0.0
@schematics/angular               8.0.0
@schematics/update                0.800.0
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

alialtun14 avatar May 31 '19 02:05 alialtun14

Duplicate of https://github.com/angular/angular-cli/issues/14554?

trotyl avatar May 31 '19 07:05 trotyl

@trotyl, not really

alan-agius4 avatar May 31 '19 10:05 alan-agius4

@alialtun14, can you provide some more info, such as which command are you using is it a ng serve or ng build?

Would you be able to provide a reproduction please?

alan-agius4 avatar May 31 '19 10:05 alan-agius4

We used static:true in ViewChild.
There are 884 ViewChild reference, 602 Component and 130 NgModule in the project. There was no other change on the code after upgrade to Angular 8.

@ViewChild(Hplan_edt, {static:true}) vEdt: Hplan_edt

"ngs": "node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng" ./ngs build --prod --aot

Date: 2019-05-30T23:13:42.637Z Hash: bc9a0deb6bb8ebe553f6 Time: 3147254ms
chunk {0} runtime.741402d1d47331ce975c.js (runtime) 1.41 kB [entry] [rendered] chunk {1} main.da4147c72278bc767ee4.js (main) 12.3 MB [initial] [rendered] chunk {2} polyfills.d1a27bf3fd244fcce0a9.js (polyfills) 42.9 kB [initial] [rendered] chunk {3} polyfills-es5.69d2f902b7fa654ec4d5.js (polyfills-es5) 68 kB [initial] [rendered] chunk {4} styles.caf2a2f780d5fba96541.css (styles) 102 kB [initial] [rendered] chunk {5} vendor.e77a5f68f74bfb5bb1a2.js (vendor) 954 kB [initial] [rendered] chunk {scripts} scripts.c05cd6675c6d364a689d.js (scripts) 228 kB [entry] [rendered]

alialtun14 avatar May 31 '19 11:05 alialtun14

Do you use sass as your style pre-processor? If yes, can you try a couple of things please:

npm i  fibers --save-dev

Run the build and report the timings

npm i node-sass -save-dev

Thanks

Run the build and report the timings.

alan-agius4 avatar May 31 '19 13:05 alan-agius4

@alan-agius4 Thank you for your attention and effort.

I have compiled again after doing the operations you said. The result has not changed. The compile process is waiting for about half an hour while 25%. The same project takes less than 40 seconds to compile with ng serve instead of ng build --prod --aot.

I have been working on upgrading to angular 8 for two days. The project actually does not have too much dependency, which may be likely to be the problem. There are only hammerjs and quill. I think I'll use angular 7.2 for a temporary solution.

alialtun14 avatar Jun 01 '19 05:06 alialtun14

After convert to angular 7.2.15, I compile the project with node 12 environment . The compile time is 5527.777 ms (6 times more than normal)

Then I installed the node 10.16.0 for angular 7.2.15 and the compile time is 901.372ms (normal)

Node: 12.3.1 + Angular: 7.2.15

Angular CLI: 7.3.9 OS: win32 x64 webpack: 4.29.0 TS: 3.2.4

Date: 2019-06-01T17:57:21.347Z
Hash: 003a017db26b2761ba40
Time: 5527.777ms
chunk {0} runtime.26209474bfa8dc87a77c.js      (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.d422ca0dc6cf56ee2633.js            (main) 12.2 MB [initial] [rendered]
chunk {2} polyfills.918ead405a6828219c02.js  (polyfills) 42.9 kB [initial] [rendered]
chunk {3} styles.a9ca052bcbe1e2ca9a8a.css       (styles)  104 kB [initial] [rendered]
chunk {4} vendor.bd9fcb891d7c323ba04b.js        (vendor)  927 kB [initial] [rendered]
chunk {scripts} scripts.c05cd6675c6d364a689d.js (scripts) 228 kB [entry] [rendered]

Node: 10.16.0 + Angular: 7.2.15

(Angular CLI: 7.3.9 OS: win32 x64 webpack: 4.29.0 TS: 3.2.4

Date: 2019-06-01T18:29:19.549Z
Hash: 003a017db26b2761ba40
Time: 901.372ms
chunk {0} runtime.26209474bfa8dc87a77c.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.d422ca0dc6cf56ee2633.js (main) 12.2 MB [initial] [rendered]
chunk {2} polyfills.918ead405a6828219c02.js (polyfills) 42.9 kB [initial] [rendered]
chunk {3} styles.a9ca052bcbe1e2ca9a8a.css (styles) 104 kB [initial] [rendered]
chunk {4} vendor.bd9fcb891d7c323ba04b.js (vendor) 927 kB [initial] [rendered]
chunk {scripts} scripts.c05cd6675c6d364a689d.js (scripts) 228 kB [entry] [rendered]

Node: 12.3.1 + Angular 8.0

Date: 2019-05-30T23:13:42.637Z
Hash: bc9a0deb6bb8ebe553f6
Time: 3147.254ms  
chunk {0} runtime.741402d1d47331ce975c.js (runtime)      1.41 kB [entry] [rendered]
chunk {1} main.da4147c72278bc767ee4.js (main)           12.3 MB [initial] [rendered]
chunk {2} polyfills.d1a27bf3fd244fcce0a9.js (polyfills) 42.9 kB [initial] [rendered]
chunk {3} polyfills-es5.69d2f902b7fa654ec4d5.js (polyfills-es5) 68 kB [initial] [rendered]
chunk {4} styles.caf2a2f780d5fba96541.css (styles) 102 kB [initial] [rendered]
chunk {5} vendor.e77a5f68f74bfb5bb1a2.js (vendor) 954 kB [initial] [rendered]
chunk {scripts} scripts.c05cd6675c6d364a689d.js (scripts) 228 kB [entry] [rendered]

alialtun14 avatar Jun 01 '19 18:06 alialtun14

Hi @alialtun14, from what you provided above, it's seems that it is slower on Node 12 irrispective of the Angular CLI version, if anything version 8 is much faster than version 7 on Node 12. 3147.254ms versus 5527.777ms.

This will require some digging to determine why the build is faster on Node 10 compared to Node 12.

I couldn't help but notice that for version 7 the compilation takes less than 1 second which doesn't seem to be right.

Would you be able to share your application please?

alan-agius4 avatar Jun 03 '19 08:06 alan-agius4

angular 7.2.15 project code without any error. Half an hour ago on my first share, I had a mistake. I corrected the error and shared it again.

angular.7.2.15.proje_v2.zip

to convert the project to angular 8, the is only two term in the project.

2  lines:   @ContentChild(... 
579 lines:  @ViewChild(...

alialtun14 avatar Jun 03 '19 21:06 alialtun14

Hi @alialtun14,

Thanks for the reproduction, we'll try to take a close look soon.

In the meantime I am going to close this issue in favor of https://github.com/angular/angular-cli/issues/13734 so that we have this issue tracked in a single tread.

Thanks for understanding.

alan-agius4 avatar Jun 05 '19 05:06 alan-agius4

I'm upgrading an application from Angular 7 to 8 and I'm also facing a huge impact in the compilation time, but I don't think it is related to #13734 (I don't see any error messages and everything works fine). The application is relatively complex (51 chunks total).

The compilation process percentage reaches the 100% and then it starts again from 0%.

I'm not using --aot, just ng build --prod --base-href /

Time to build:

  • real 9m14,118s
  • user 15m22,745s
  • sys 0m15,490s

I've then revert to Angular 7.2 and I get these values:

  • real 4m43,201s
  • user 8m29,736s
  • sys 0m7,659s

adripanico avatar Jun 12 '19 09:06 adripanico

Same problem here too...

micobarac avatar Jun 18 '19 08:06 micobarac

Overall angular-cli is two times slower and consumes more memory than custom script with rollup or closure and even webpack. CI times are much worse.

kemsky avatar Jun 18 '19 09:06 kemsky

It seems it has been improved in @angular/cli 8.0.3 according to https://github.com/angular/angular-cli/issues/14746.

adripanico avatar Jun 18 '19 10:06 adripanico

Hi all,

I faced the same problem too, even in the 8.0.3 version.

In my case, going back to native Sass (explained here https://update.angular.io/#7.0:8.0) fix the problem (I now have the same compilation time than with Angular 7).

For me, the JS compiler seems to be extremely slow with sass files.

Alcidauk avatar Jun 18 '19 16:06 Alcidauk

Upgrading to cli 8.0.3:

real	7m4,341s
user	13m36,479s
sys	0m11,740s

Upgrading to cli 8.0.3 and using node-sass:

real	8m45,860s
user	15m18,098s
sys	0m14,003s

adripanico avatar Jun 19 '19 13:06 adripanico

Upgrading to cli 8.0.4:

real	7m50,181s
user	15m3,919s
sys	0m12,322s

Upgrading to cli 8.0.4 and using node-sass:

real	8m8,383s
user	15m0,839s
sys	0m13,394s

adripanico avatar Jun 25 '19 12:06 adripanico

Sorry but: So no one can seriously work with the new compiler for angular 8. It hardly goes slower anymore. An impertinence for every developer! We must wait 20 minutes to get an error message! And then we get an error message that doesn't say anything!

The issue is open and not closed !

j-nord avatar Jul 23 '19 14:07 j-nord

Sorry but: So no one can seriously work with the new compiler for angular 8. It hardly goes slower anymore. An impertinence for every developer! We must wait 20 minutes to get an error message! And then we get an error message that doesn't say anything!

The issue is open and not closed !

I'm seriously working with the new compiler. I assume your "doesn't-say-anything" error is something miss-configured or any kind of issue during the upgrading on your side.

I don't think this error belongs to this issue: we are talking about compilation time here.

adripanico avatar Jul 23 '19 15:07 adripanico

Yes and the compilation time in angular 8 is toooooooo slow!

j-nord avatar Jul 23 '19 15:07 j-nord