Getting "WARNING in Circular dependency detected" when referencing components from single "barrel" file
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.
You can disable warning by adding this in the section Architect > Build > Options "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "showCircularDependencies": false,
I noticed that I get this error if you forget to specify the file endings for the template url or style urls. Exmaple:
templateUrl: 'my.component'should better betemplateUrl: 'my.component.html'.
i don't know why i didn't add the file ending in the first place, but this was exactly my problem. thanks @mark-langer
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.