简体   繁体   中英

WARNING in Circular dependency detected: barrelsby Angular 10

I am getting circular dependency warning while using barrelsby in Angular 10.

Error: 
WARNING in Circular dependency detected:
src\app\core\components\components.module.ts -> src\app\core\components\header\header.component.ts -> src\app\state\index.ts -> src\app\core\components\components.module.ts

Structure:

/component
  /header
    header.component.ts
    index.ts

index.ts

export * from './header.component';

component.module.ts

import { HeaderComponent } from './header';

@NgModule({
  imports: [],
  exports: [
    HeaderComponent,
  ],
  declarations: [
    HeaderComponent
  ]
})

index.ts

export * from './header/index';

It's just a warning so you don't absolutely need to fix it. The warning tells you where the circle is:

  • module imports from header
  • header imports from index
  • index imports from module

In order to break the circle, I would avoid importing from index. Whichever component header is importing from index, import it from that components folder instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM