WARNING in Circular dependency detected: barrelsby Angular 10

Viewed 1021

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';
1 Answers

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.

Related