fix(contract) Compile the contract so plain Node can load its runtime constants #13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "build-contract-for-node"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
recipe-backendcrashes at startup onstagesince it was onboarded onto the contract (backend PR #13):The backend imports the contract's
as constenum objects (UserRole,RecipeImportStatus,MealPlanPermission,RecipeSortField, …) as values, so its compiledbuild/*.jskeepsimport … from "@recipe/contract". Plain Node cannot loadsrc/index.ts. Type-only imports andrecipe-app(Vite) were unaffected, which is why the crash didn't show up earlier.Change
api-contract/package.jsonprepare: tsc(plus abuildalias). Everynpm installinsideapi-contract/, both the ONBOARDING step and each sibling's CIinstall_platform_contractstep, now emitsdist/using the existingtsconfig.json.dist/stays git-ignored.exportsmap:types→src/index.ts(tsc)module→src/index.ts(Vite client builds)development→src/index.ts(Vite dev server and Vitest; Node never sets this condition)default→dist/index.js(plain Node)docs/adr/2026-09-26-contract-node-runtime-build.md. It replaces the "no build step" statement of2026-09-13-ts-rest-api-contract.mdfor Node runtimes; that ADR itself is untouched.CLAUDE.mdandONBOARDING.mddocument the new rebuild step: after editing the contract, runnpm run buildinapi-contract/before restarting the backend.Verification
tscpasses, 366/366 tests pass, and plainnodeimports the constants fromdist/.tsc -b, 187/187 tests andvite buildpass.recipe-appneeds no changes.dist/deleted, so Vite and Vitest read the source and never see a stale build.Merge order
Merge this before recipe-backend's
ship-built-contractPR. The backend's CI clonesrecipe-platformatmain, so its deploy fix depends on this being there.🤖 Generated with Claude Code