Do you use any tooling to detect this? I had this issue some years back and it wasn't obvious. My builds just took longer and longer.
These are my package.json scripts for detecting cycles:
"cycles": "run-p cycles:client cycles:server",
"cycles:client": "dpdm client/src/\*/\*.ts --exit-code circular:1",
"cycles:server": "dpdm server/src/server.ts --exit-code circular:1",
The exit code is set like that so that the CI will fail on cycles, since we run this in our CI build.I also hear people use ESLint, probably this: https://github.com/import-js/eslint-plugin-import/blob/main/...
The fact that the compiler itself doesn't error on cycle imports, and that the errors caused by those imports are so opaque, seems like an oversight to me.
https://github.com/sverweij/dependency-cruiser
NX[0] also has logic for handling this issue
[0]: https://nx.dev/