Angular Circular Dependencies - removing showCircularDependency flag has resulted in problems for big enterprise applications #24870
Comments
Hi, The problem with Circular dependencies is more suited for a linter/external tool than a build step. One point to consider is that cycles dependencies in ES modules are allowed. If Eslint circular dependency checker is slow is suggest you file an issue with the other of the rule. |
HI @alan-agius4 ... Thanks for responding... |
We are using madge successfully, it does find all circular dependencies. I have two notes on its use: A) type-only circular imports are OK, you can ignore these with
B) madge only emits warnings when the imported file is not found (can be made more verbose with
but import checking obviously stops at the file that was not found. You need to run madge with a tsconfig file that has all path mappings so the imported files can be found (i.e. no warnings) |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are relevant/related to the feature request?
No response
Description
Angular has removed the showCircularDependency flag. I understand it is for performance improvement, But for already existing big enterprise-level applications, with many developers, it poses a big problem. Since many devs are working, an import-based circular dependency can be easily inserted in any part of the code, and with the useful 'circular dependency warnings' removed, there is no way to find such issues. And these issues may cause application to actually break in production. Which causes a huge impact on our reputation with the customer. We tried the alternatives suggested, but no luck
Eslint -> import/no-cycle -> Makes our linter in CI run for more than 1.5 hours and finally breaks
14:55:00 Linting "@abcd/mnop-efgh"...
16:27:07 Cannot contact xyz-slave1: java.lang.InterruptedException
This is probably because our application is very big
Madge -> Only found the type-based circular dependencies and no other circular dependencies... It is able to detect all circ-deps for a smaller application, But since our app is huge it is probably not able to find anything relevant.
Proposed solution
Keep the showCircularDependencies flag for development and not have it in production. In the angular.json we can have a warning, if showCircularDependencies is set to true, stating, "Do not use in Production as it will slow the build".
Angular can have another script, which after running can let us know the circular dependency warnings. This script can be based on the build, used in Angular-13 or before... which finds circular dependencies. This script will be different from the build so no performance impact will be there.
Alternatives considered
As mentioned above eslint and madge were tried, but no value was added.
The text was updated successfully, but these errors were encountered: