Skip to content

Getting "WARNING in Circular dependency detected" when referencing components from single "barrel" file #7705

@williamBurgeson

Description

@williamBurgeson

See https://github.com/williamBurgeson/circ-ref for an example of this problem.

In my project, I have used a "all-components" and "all-services" file in each folder to tidy up the imports, but at some point with angular-cli between 1.2.7 and 1.4.1 this started provoking warnings such as below:

WARNING in Circular dependency detected:
src/app/all-components.ts -> src/app/hello/hello.component.ts -> src/app/all-components.ts

WARNING in Circular dependency detected:
src/app/hello/hello.component.ts -> src/app/all-components.ts -> src/app/hello/hello.component.ts

I have seen issues logged to the effect that warnings were desirable, however in this case the project builds and works fine apart from showing the same warnings in the console, and when run with the --prod switch no warnings are provoked.

As the sample app shows, both the "hello" and "goodbye" components are redeclared in the "all-components.ts" file, through which the app.component and app.module reference them as necessary. The "hello" component also references the "goodbye" component programmatically, in order to set a property.

I know it's possible to set properties exclusively through the HTML, however the requirements of my project are such that I need to reference components, sometimes with a circular dependency (as I might have done with classes in .net for example)

Ideally, this "feature" would be amended, to check if the circular references really are harmful, and either removed, made less sensitive, or some way can be offered to allow in a given situation such as mine to prevent the warning occurring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions