Repository navigation
refactor(web): import dialect code through @foxschema/ui-shared - #488
Merged
Merged
Conversation
The frontend imported @foxschema/sql directly from 65 files, so what the browser depended on was spread across features and grew with every new import. The engine is shared with the server, the CLI and the driver layer. Add packages/ui-shared: one file that names each @foxschema/sql export the frontend uses (183 values, 127 types, grouped by area) and re-exports it by reference. apps/web now depends on it instead of @foxschema/sql, and every frontend import goes through it. Guards: - architecture.test.ts fails on any frontend import of @foxschema/sql. - ui-shared.test.ts checks every export is the @foxschema/sql object itself (no copies that could drift), that the package imports nothing else, and that it uses no `export *`, so new browser use shows up in review. - naming.test.ts recognises a facade by its @foxschema/ui-shared import. The web build is byte-for-byte identical (same 102 chunks and hashes; first load still 140.3 KB gzip). Docs: ARCHITECTURE, CODE_MAP, CONVENTIONS, CONTRIBUTING. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PyNv48vpYUw2HhpjYFNUi
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 73afb744-23d7-4fdd-a2f1-1ee411fbfd3b) |
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.
Why
The web frontend imported
@foxschema/sqldirectly from 65 files. That package is the dialect engine the server, the CLI and the driver layer share, so what the browser depended on was spread across features and grew with every new import.What
packages/ui-shared(@foxschema/ui-shared). Oneindex.tsthat names each@foxschema/sqlexport the frontend uses (183 values, 127 types, grouped by area) and re-exports it by reference. No code moves and nothing is wrapped.apps/webdepends on@foxschema/ui-sharedinstead of@foxschema/sql. All 78 frontend import lines were re-pointed one for one. Aliases were added toapps/web/vite.config.ts,apps/web/tsconfig.jsonand the rootvitest.config.ts. The lockfile change only adds the workspace link; no third-party versions change.apps/web/src/frontend/architecture.test.tsfails on any frontend import of@foxschema/sql.packages/ui-shared/src/ui-shared.test.tschecks three things:@foxschema/sqlobject itself, so the browser and the server cannot drift apart;@foxschema/sql;export *, so the browser taking on more of the engine shows up in review.packages/shared/src/naming.test.tsnow recognises a kebab-case frontend facade by its@foxschema/ui-sharedimport, and includes the new package in its kebab-case check.ARCHITECTURE.md,CODE_MAP.md(import rules, plus a "Where does my change go?" row),CONVENTIONS.mdandCONTRIBUTING.mdare updated.To use something new from the engine in the browser, add it to
packages/ui-shared/src/index.ts.Verification
cd apps/web && npx tsc --noEmit: clean.npx vitest run(Node 24): 479 files passed, 8 skipped; 5858 tests passed.npx eslinton the changed files: clean.@foxschema/sqlimport;export *;node:fsimport.npm run build -w @foxschema/webproduces the same 102 JS chunks, with the same hashes and total size, asmain.npm run bundle:first-loadreports 140.3 KB gzip, within the 170 KB budget.🤖 Generated with Claude Code
https://claude.ai/code/session_016PyNv48vpYUw2HhpjYFNUi
Generated by Claude Code
Note
Low Risk
Import-path and package-boundary refactor with tests and docs; runtime behavior and bundle are unchanged per verification.
Overview
Introduces
@foxschema/ui-sharedas the web app’s single entry for dialect engine APIs: a named, by-reference re-export of@foxschema/sql(no wrappers or moved code).apps/webdrops a direct@foxschema/sqldependency and re-points frontend imports and shared facades to@foxschema/ui-shared, with matching Vite/tsconfig/Vitest aliases.Enforcement and docs:
architecture.test.tsfails on any frontend@foxschema/sqlimport;ui-shared.test.tschecks same-object re-exports, no extra deps, and noexport *. CONTRIBUTING, ARCHITECTURE, CODE_MAP, and CONVENTIONS describe the new boundary;naming.test.tstreats@foxschema/ui-sharedfacades correctly.Workflow for browser use: add exports to
packages/ui-shared/src/index.tsinstead of importing the engine package from features.Reviewed by Cursor Bugbot for commit fd6ef58. Bugbot is set up for automated code reviews on this repo. Configure here.