Repository navigation
fix(deps): make the circular-dependency check actually check - #780
Merged
Merged
Conversation
`pnpm check-circular-deps` was `nx show projects --json > /dev/null` — it listed projects and threw them away. `test:deps` and `test:deps:strict` both call it, so both had always passed, and a circular import could land with nothing noticing (#777). Wiring `scripts/check-circular-deps.sh` in as it stood would have replaced one no-op with a better-looking one. madge defaults to JavaScript extensions, so pointed at this repo it reports: Processed 0 files (270ms) ✔ No circular dependency found! A green check that read nothing. So the script now passes `--extensions ts,tsx`, and **treats a root that yields no files as an error** — that is the failure this issue is about, and it would otherwise have recurred one layer down. It also reads madge's exit code instead of string-matching its success message, takes several roots, and quotes its arguments. `check-circular-deps` now runs against `apps/scaffald`, `packages/scf-core` and `packages/supabase/functions`: ~1,770 files in about 12s, fast enough for the pre-push path, so it stays in `test:deps` rather than `strict` only. **The first real run found three cycles**, all one barrel importing its own consumers: trpc/routers/utils/storage-backends/index.ts > dropbox-backend.ts trpc/routers/utils/storage-backends/index.ts > google-drive-backend.ts trpc/routers/utils/storage-backends/index.ts > supabase-backend.ts `index.ts` both declared the `IStorageBackend` contract and re-exported the three implementations, each of which imported the contract back from it. The imports are `import type`, so nothing broke at runtime — but it is a real cycle in the module graph and stops being harmless the first time one of them needs a value. The contract moves to `types.ts`; `index.ts` is a barrel of re-exports; the backends import from `types.ts`. Verified in every direction rather than on one green run: all three roots ✓ 234 / 1177 / 358 files, exit 0 deliberate 2-file cycle in scf-core ✗ "Found 1 circular dependency", exit 1 cycle removed ✓ exit 0 root with no ts files ✗ "processed no files", exit 1 path that does not exist ✗ "not a directory", exit 1 `scripts/README.md` gains a Dependency checks section and drops this script from "Manual tools (not wired to package.json)", which it no longer is. Closes #777 Co-Authored-By: Claude Opus 5 <[email protected]>
`supabase:typecheck` failed on the previous commit:
storage-router.ts(12,3): error TS2305: Module
'./storage-backends/index.ts' has no exported member 'StorageRouterResult'
Splitting the contract out of the barrel was right; listing the re-exports by
hand was not. I enumerated six and `types.ts` declares seven, so the barrel
silently narrowed its own surface — which is the one thing a barrel exists to
prevent.
`export *` instead. There is no reason to maintain that list by hand.
Co-Authored-By: Claude Opus 5 <[email protected]>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pnpm check-circular-depswasnx show projects --json > /dev/null— it listedprojects and threw them away.
test:depsandtest:deps:strictboth call it, soboth had always passed, and a circular import could land with nothing noticing
(#777).
Wiring
scripts/check-circular-deps.shin as it stood would have replaced oneno-op with a better-looking one. madge defaults to JavaScript extensions, so
pointed at this repo it reports:
A green check that read nothing. So the script now passes
--extensions ts,tsx,and treats a root that yields no files as an error — that is the failure this
issue is about, and it would otherwise have recurred one layer down. It also
reads madge's exit code instead of string-matching its success message, takes
several roots, and quotes its arguments.
check-circular-depsnow runs againstapps/scaffald,packages/scf-coreandpackages/supabase/functions: ~1,770 files in about 12s, fast enough for thepre-push path, so it stays in
test:depsrather thanstrictonly.The first real run found three cycles, all one barrel importing its own
consumers:
index.tsboth declared theIStorageBackendcontract and re-exported the threeimplementations, each of which imported the contract back from it. The imports
are
import type, so nothing broke at runtime — but it is a real cycle in themodule graph and stops being harmless the first time one of them needs a value.
The contract moves to
types.ts;index.tsis a barrel of re-exports; thebackends import from
types.ts.Verified in every direction rather than on one green run:
scripts/README.mdgains a Dependency checks section and drops this script from"Manual tools (not wired to package.json)", which it no longer is.
Closes #777
🤖 Generated with Claude Code