1

I need access to sharedModule=>random.component inside coreModule... Currently, I get circular dependency errors. Should I keep trying to do this or is it inherently wrong?

here is my current app structure

app.module.ts

-> Imports: core.module.ts

core.module.ts

-> Imports: shared.module.ts (i think this is causing circular dependency

shared.module.ts

  • it is imported by whatever feature module needs

  • app.module.ts also imports it

  • core is importing it because it holds my log.service.ts

  • can predict there will be other things needed in core from shared

shared.module.ts ===> log.service.ts

  • this is in shared because it's not expected to be a singleton
  • Tried removing the share import in core and simply importing log.service in the core component but now core won't

if it's wrong for core to imports shared. How can core gain access to things in shared

10
  • I'm not seeing a circular reference here. It just goes App => Core => Shared. And App => Shared. Which is fine. Are you sure there are no imports going the other way, e.g. Shared importing Core? Commented Dec 20, 2020 at 21:20
  • feature and shared modules do not import core but shared components do use singleton services from core eg import { GlobalService } from 'meteorite-core'; ... no mention of core was made in shared.module Commented Dec 20, 2020 at 21:23
  • if its wrong for core to imports shared. How can core gain access to things in shared You can import it wherever you want - unless shared module is not importing that part. YOu will get circular dependency. Commented Dec 20, 2020 at 21:23
  • @Omar thats your circularity. Since share is using core - it shouldnt be separated in the first place. Commented Dec 20, 2020 at 21:23
  • i see. so core has global.service (singleton) which is needed in almost every shared or feature module. how do i achieve this? @Antoniossss Commented Dec 20, 2020 at 21:25

2 Answers 2

0

Since shared module imports main module but only for one of it services, make that service a separate module. Doing that will allow you to import that particular module(service)anywhere you want.

Sign up to request clarification or add additional context in comments.

Comments

0

You should not import the sharedModule in the coreModule, this contradict the whole purpose. CoreModule is where you load components/modules/prodivers etc that you use through out your entire applications and this should ONLY be imported in the appModule. SharedModule is used in your featureModules.

Also search ( Ctrl+F ) your application for CoreModule, maybe you are also importing it somewhere else.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.