ci: add circular dependency check for package entrypoints#8003
ci: add circular dependency check for package entrypoints#8003mimecuvalo merged 6 commits intomainfrom
Conversation
Add a CI guard using vite-plugin-circular-dependency so circular imports in package entrypoints are caught early and we don't regress after #7935. Co-authored-by: Cursor <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
packages/editor/src/lib/components/default-components/DefaultLoadingScreen.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| }, | ||
| }, | ||
| }) | ||
| cycleReport = JSON.parse(readFileSync(outputFilePath, 'utf8')) |
There was a problem hiding this comment.
Unchecked file read assumes plugin creates output file
Medium Severity
The code unconditionally reads outputFilePath after the Vite build completes, assuming vite-plugin-circular-dependency always creates the file. If the plugin doesn't create the file (due to a plugin issue, file system error, or unexpected behavior), readFileSync throws an error that gets caught at line 175 and swallowed, incorrectly marking packages as failed even when they have no circular dependencies.
| packageEntryPath, | ||
| JSON.stringify(includePatternSets), | ||
| ], | ||
| { cwd: REPO_ROOT }, |
There was a problem hiding this comment.
Missing maxBuffer could cause false check failures
Medium Severity
The execFile call lacks a maxBuffer option, defaulting to 200KB. When checking packages with verbose Vite builds or extensive circular dependency reports, output can exceed this limit, causing Node to kill the child process with a buffer overflow error. The package would be incorrectly marked as failed even if the check itself succeeded. Other scripts in this codebase use maxBuffer: 50 * 1024 * 1024.
i originally removed these but they're necessary to keep things speedy ## Summary - document why tldraw checks use dynamic batched include sets with `vite-plugin-circular-dependency` - reduce tldraw scan runtime by combining safe scopes while keeping `ui/components` and `ui/context` separate to avoid plugin `Invalid array length` crashes - run scoped checks with bounded concurrency to improve local and CI performance without reducing coverage Follow-up to #8003. Related to #7935 and #2458. ### Change type - [x] `other` ## Test plan - [x] Run `yarn check-circular-deps` - [x] Run `time yarn check-circular-deps` and verify improved runtime Made with [Cursor](https://cursor.com) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Build-time CI script changes only; main risk is false negatives/positives if the new include batching misses files or alters scan boundaries. > > **Overview** > Speeds up `yarn check-circular-deps` by changing `tldraw`’s include patterns from per-scope scans to **filesystem-discovered batches**, scanning all non-UI scopes together while keeping `ui/components` and `ui/context` isolated to avoid `vite-plugin-circular-dependency` “Invalid array length” crashes. > > Also runs each include-set check via a small worker queue with **bounded concurrency** (up to 2 for `tldraw`) instead of strictly serial execution, improving CI/local runtime without reducing coverage. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f2393ce. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Cursor <[email protected]>


Summary
vite-plugin-circular-dependencyand a newyarn check-circular-depsscriptpackages/*/src/index.tsentrypointsFollow-up to #7935.
Related to #2458.
Change type
otherTest plan
yarn check-circular-depsCheck circular dependenciesMade with Cursor
Note
Medium Risk
Adds a new CI gate that may introduce flaky/slow builds or unexpected failures on certain package graphs. The code refactor is mostly import/move-only but touches core arrow geometry helpers used widely in
tldraw.Overview
CI now blocks circular imports. Adds
yarn check-circular-depsand wires it into the mainChecksworkflow, usingvite-plugin-circular-dependencyto scan eachpackages/*/src/index.tsentrypoint (with scoped splitting forpackages/tldrawto avoid large-graph crashes).Separately, refactors arrow utilities by extracting
getArrowInfofromshapes/arrow/shared.tsinto a newgetArrowInfo.tsmodule and updating all imports/exports accordingly, and tweaks editor component imports plusDefaultLoadingScreento render its own.tl-loadingwrapper instead of relying onTldrawEditor’sLoadingScreencomponent.Written by Cursor Bugbot for commit 4042079. This will update automatically on new commits. Configure here.