Circular dependency when trying to import shared components into shell module (SharedModule <-> ShellModule).
See original GitHub issueI want to use ish-content-include
to make it possible for the client to edit the header navigation menu items. However to use ish-content-include
I have to import sharedModule
into shellModule
. ShellModule already is being imported by sharedModule, so when i import sharedModule they will depend on eachother creating a circular dependency and giving the error Maximum call stack exceeded
.
How can I solve this issue?
Note: This will be used as reference and discussed tomorrow with the internal intershop team
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (1 by maintainers)
Top Results From Across the Web
angular --Import sharedModule inside the coreModule without ...
I'm not seeing a circular reference here. · feature and shared modules do not import core but shared components do use singleton services...
Read more >NG0200: Circular dependency in DI detected while ... - Angular
You will be able to see if any child dependencies rely on the original file by mapping out the component, module, or service's...
Read more >How to fix nasty circular dependency issues once and for all in ...
In the many projects I have maintained so far, sooner or later I always run into the same issue: circular module dependencies.
Read more >How to resolve "Circular dependency" in NRWL #2570 - GitHub
I am getting the below LINT error. "Circular dependency between "A(lib)" and "B(lib)" detected (nx-enforce-module-boundaries) tslint error"
Read more >Circular Dependency Nightware : r/Nestjs_framework - Reddit
I'm gonna try do this suggestion of the shared/core module where all of my services and models will only be imported into the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @adrianResler,
Yes, if this PR is merged, it should be possible to do this for any component in the shared module by calling the
lazy-component
schematic. With your example:For projects this is a good approach and nothing really speaks against it. By adding lazy component wrappers to the shell the initial bundle doesn’t grow as significantly as moving components to the shell module would do. But if this is overused, the code can become quite unreadable.
For the PWA itself I’d rather propose a refactoring and lazy-fy the line item list for the mini-basket in #528 like you just inspired me to do:
https://github.com/intershop/intershop-pwa/blob/e2f1574d5a1a951106b8673d1461b1937ab38174/src/app/shell/header/mini-basket/mini-basket.component.html#L18-L20
That way also the
ish-product-image
component can be moved to the shared module so the initial bundle gets smaller.I have taken a good look at it and tried to de-couple
shellModule
fromsharedModule
. However as i kept decoupling i found out there’s a decision being made a while ago which makes this quite a big investment to decouple.The
shellModule
in my opinion should not be treated as a sharedModule, it should not be a “foundation” for another module. It should be a dead-end for header/footer/whatever. While I do have an opinion on a business perspective this isn’t feasible because of the time investment.so we are going with the provided route of something like https://github.com/intershop/intershop-pwa/pull/496.
Thank you for your time and for the quick replies!