Solve circular dependencies
🐜 Bug report
🔧
about: Short explanation At the moment there are several circular dependencies in the project, i.e. imports between files that result in a loop, like
a ==imports==> b ==imports==> a
This can result in unexpected behavior like imported objects being undefined
even though they should not and might lead to pipeline or build failures in some cases, unexpected run time errors in others.
What is the expected behaviour?
There should be no circular dependencies in the project.
What is the actual behaviour?
There are circular dependencies in the project.
Steps to Reproduce
There is a command line tool that can be used to analyze the import structure and show circular dependencies: Madge
Running
npx madge --ts-config ./tsconfig.json --extensions js,ts --circular .
shows 8 circular dependencies:
1) lib/common/src/settings/settings.commons.ts > lib/common/src/settings/settings.module.ts > lib/common/src/settings/overview-page/overview-page.component.ts
2) lib/common/src/settings/settings.commons.ts > lib/common/src/settings/settings.module.ts > lib/common/src/settings/overview-page/overview-page.component.ts > lib/common/src/settings/settings.service.ts
3) lib/common/src/settings/settings.module.ts > lib/common/src/settings/overview-page/overview-page.component.ts > lib/common/src/settings/settings.service.ts
4) lib/common/src/settings/settings.commons.ts > lib/common/src/settings/settings.module.ts
5) lib/common/src/meta-store/meta-store.class.ts > lib/common/src/meta-store/meta-store.commons.ts
6) lib/common/src/overlays/relay/relay-modal.component.ts > lib/common/src/overlays/relay/relay-modal.service.ts
7) lib/common/src/ui-components/icons/icon.service.ts > lib/common/src/ui-components/icons/icon.component.ts
8) lib/core/src/utils/calendar-date-strings.ts > lib/core/src/utils/date.ts
It can also put out a nice graph when you have Graphviz installed (see below) :)
Screenshots
Files
See list of circular dependencies above
Any possible solutions?
Reorganize inputs and/or refactor exports. Combining objects in a file can help sometimes, or moving an exported object to its own file so a and b import from c but not each other anymore.