Lazy-loaded circular dependent components break live-reload
See original GitHub issue🐞 Bug report
Command (mark with an x
)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- xi18n
- run
- config
- help
- version
- doc
Is this a regression?
Yes, the previous version in which this bug was not present was: 9.x
Description
In a specific scenario, changes to component code (template, styles, ts) result in erroneous js and an exception in the browser: ReferenceError: Cannot access 'AComponent' before initialization
. In another scenario, a component stops rendering right after a given change in the template. See video for details.
This happens in the following scenario:
- Routing is used
- Affected components are lazy-loaded
- Components are circular dependent, i.e. imaine a tree-like data-structure, where nodes have child-nodes of the same type
- Components are not directly but indirectly nested: a -> b -> c -> a -> b -> c -> a
Changing anything (e.g. a color in the styles) bricks the live-reloaded app.
🔬 Minimal Reproduction
Repo: https://github.com/scheja/repro-app (Basic app, generated with ng new --routing
)
Start with ng serve
, go to http://localhost:4200/lazy
, then start editing e.g. src/app/lazy/c/c.component.html
and watch what happens.
Quick screen recording: https://youtu.be/d7Ch0pEPtNQ
🔥 Exception or Error
ReferenceError: Cannot access 'AComponent' before initialization
🌍 Your Environment
Angular CLI: 10.1.3
Node: 14.10.1
OS: darwin x64
Angular: 10.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1001.3
@angular-devkit/build-angular 0.1001.3
@angular-devkit/core 10.1.3
@angular-devkit/schematics 10.1.3
@schematics/angular 10.1.3
@schematics/update 0.1001.3
rxjs 6.6.3
typescript 4.0.3
Anything else relevant? Related to: https://github.com/angular/angular-cli/issues/18183 (this might be the need: repro steps)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:7 (4 by maintainers)
Top GitHub Comments
I’m adding the reproduction from #39458 here as well; it shows that this happens even without lazy modules: https://github.com/algcifaldi/repro-not-strict
This should now be fixed in version 11.1. When using the above reproduction with version 11.1, the errors no longer appear to be present. If you are still encountering problems when using 11.1, please let us know.