question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
JoostKcommented, Oct 28, 2020

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

2reactions
clydincommented, Jan 22, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular got Circular dependency detection WARNING when ...
Circular dependency errors have nothing to do with Angular. It just means that you are importing in an infinite loop using TypeScript.
Read more >
Angular dynamic modules at runtime with Module Federation
component.html is not rendered). So I figured I can enforce it by using named outlets. However it just breaks the app completely. I...
Read more >
The Best Way To Architect Your Angular Libraries
This example will demonstrate that NOT using sub-entries breaks code splitting and causes library module C with its component C (100KB) to end...
Read more >
Lazy loading React components - LogRocket Blog
Lazy loading enables you to render elements on demand, making your app more ... and break down how they facilitate lazy loading in...
Read more >
Coding Shorts: Dependency Injection Explained - Morioh
Angular Bootstrap gallery is a component with great UI and UX values. With it you can combine beautiful and stunning images with your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found