angular-cli: Slower compilation when using @ngtools/webpack@7.1.0
Initially reported in https://github.com/angular/angular/issues/26674#issuecomment-443263655 by @sod
hm indeed, just updating ngtools gives me the slowdown. Also using angular 7.1 with old ngtools 7.0.7 is significantly faster.
versions | 1st run | 2nd run | 3rd run | 4th run | 5th run |
---|---|---|---|---|---|
@angular 7.0.4, @ngtools 7.0.7 |
31s | 15s | 7s | 5s | 5s |
@angular 7.0.4, @ngtools 7.1.0 |
29s | 14.5s | 15.5s | 12s | 12s |
@angular 7.1.1, @ngtools 7.1.0 |
29s | 13.5s | 13.5s | 15s | 16s |
@angular 7.1.1, @ngtools 7.0.7 |
28s | 12.8s | 7s | 5s | 4.2s |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (9 by maintainers)
Commits related to this issue
- revert: fix(@ngtools/webpack): emit lazy routes errors on rebuilds This reverts commit edb84b340ff996df2ca6a2aaf765304cc64fef3e The team has decided to bring back the faster but potentially less acc... — committed to angular/angular-cli by deleted user 6 years ago
- revert: fix(@ngtools/webpack): emit lazy routes errors on rebuilds This reverts commit edb84b340ff996df2ca6a2aaf765304cc64fef3e The team has decided to bring back the faster but potentially less acc... — committed to angular/angular-cli by deleted user 6 years ago
- revert: fix(@ngtools/webpack): emit lazy routes errors on rebuilds This reverts commit edb84b340ff996df2ca6a2aaf765304cc64fef3e The team has decided to bring back the faster but potentially less acc... — committed to ikjelle/angular-cli by deleted user 6 years ago
The issue is indeed that within 7.1.x the Angular compiler is always used to calculate the set of lazy routes when in JIT mode. This was initially done to guarantee that the lazy routes were calculated accurately and any lazy route related errors would be shown upon a rebuild. This has the unfortunate downside of taking more time. The underlying problem is one of correctness/accuracy versus speed.
The team has decided to bring back the faster but potentially less accurate method of detecting lazy routes upon JIT rebuilds (first builds will always use the more complete Angular compiler method). Applications that do not have lazy routes within libraries and that only use direct string literals with
loadChildren
should not be affected by the potential of less accurate detection. Note that the function overload ofloadChildren
also does not apply to this situation. For those projects where correctness of lazy route detection outweighs rebuild speed, please consider using AOT mode for development. AOT mode will also provide a full set of template errors as well which JIT mode is not capable of doing.If you have concerns about this decision, please let us know.
@psurrey It already has been. Ensure that the project is using both
@angular/cli@7.2.1
and@angular-devkit/build-angular@0.12.1
.@why520crazy, I’ll be working on this today.
Was working a bit on this today and noticed that the results I took yesterday were of rebuilds without a vendor chunk, which great inflate total rebuild times.
To get more granular information I also used an internal profiling flag we have to see where time is spent in compilations.
The results I got were:
@ngtools/webpack@7.0.7
rebuilds took ~0.5s@ngtools/webpack@7.1.0
rebuilds took ~3.3s@ngtools/webpack@7.1.2
rebuilds took ~1.1s (includes #13133)@ngtools/webpack@7.1.3
rebuilds took ~1.2s (includes extra logging from #13159)A few notes about these profiling messages:
AngularCompilerPlugin._make
is the total time taken inside the ngtools/webpack pluginTypeChecker.*
refers to the forked type checker, in a separate processMy previous guess was that syntactic diagnostics on rebuilds were still taking too long, but that doesn’t really hold true since in
@ngtools/webpack@7.1.2
they are shown to take less that 1ms (AngularCompilerPlugin._emit.ts.gatherDiagnostics.ts.getSyntacticDiagnostics: 0.317ms
).What does seem to take a lot longer is
AngularCompilerPlugin._update
, clocking in at43.407ms
in7.0.7
but increasing to616.467ms
in7.1.2
. The main contributor isAngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes
, only visible in the profile logs for7.1.3
.That increase seems related to https://github.com/angular/angular-cli/pull/12418, where the way we process lazy routes and their errors changed.
‘npm i @ngtools/webpack@7.0‘
I guess https://github.com/angular/angular-cli/pull/12824 caused this? I’m not sure if this is the intended behavior. An opt-out would be nice.