fix(dev): rebuild shared workspaces before npm run dev (#968)#970
Open
jakebromberg wants to merge 1 commit into
Open
fix(dev): rebuild shared workspaces before npm run dev (#968)#970jakebromberg wants to merge 1 commit into
jakebromberg wants to merge 1 commit into
Conversation
Adds a predev script that rebuilds @wxyc/database + @wxyc/authentication before npm run dev, mirroring the existing lint:prebuild pattern. Without this, a fresh clone or any pull that touches shared/database/src/schema.ts serves a stale schema export to the running backend — typically surfacing as `TypeError: Cannot convert undefined or null to object` deep inside drizzle-orm/utils.js with no column name to chase down (took ~20 min to diagnose during the BS#940 / dj-site#560 preview session on 2026-05-18). apps/backend's tsup --watch already rebuilds its own sources but doesn't follow workspace dep dists; predev covers the gap. Quick build (~1s for both shared workspaces against installed deps). CLAUDE.md "Running locally" updated with the why. Closes #968.
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.
Summary
Adds an
npmlifecyclepredevscript that rebuilds@wxyc/database+@wxyc/authenticationbeforenpm run dev, so a fresh clone or any pull that touchesshared/database/src/schema.tsdoesn't silently serve a stale schema export to the running backend.The failure mode this prevents is brutal to diagnose: every flowsheet read 500s with
TypeError: Cannot convert undefined or null to objectdeep insidedrizzle-orm/utils.js(orderSelectedFields), with no column name in the stack to chase. Took ~20 minutes to trace during the BS#940 / dj-site#560 preview session on 2026-05-18 before noticing thedist/index.jsmtime predated the schema commit.apps/backend/tsup --watchrebuilds its own sources but doesn't follow workspace dep dists;predevcovers the gap.Change
+ "predev": "npm run build --workspace=@wxyc/database --workspace=@wxyc/authentication",Mirrors the existing
lint:prebuildshape — same workspaces, samenpm run buildinvocation. CLAUDE.md "Running locally" gets a one-paragraph note explaining the why.Test plan
shared/database/dist+shared/authentication/dist; rannpm run predev. Both rebuilt successfully (DTS clean, ~1s wall clock). Verifiedflowsheet.track_position(the symbol whose absence trips the original bug) is present in the regenerateddist/index.js.npm run devnow chainspredevfirst per npm lifecycle convention. Already runsdotenvx run -f .env -- concurrentlyfor the actual dev startup;predevruns in a separate shell invocation so dotenvx wrapping is irrelevant.lint:prebuildalready covers the shared-workspace rebuild for lint/typecheck/build CI jobs, so CI is untouched.Notes
--workspaces --if-present? Would also buildapps/*andjobs/*, whichtsup --watchindev:backend/dev:authalready handles. ~1s vs ~5s startup delta isn't a lot, but the explicit-list approach matcheslint:prebuildand is self-documenting../src/index.ts? Bigger change with implications for production build paths; the predev path is the smaller fix and matches the in-flight convention. If anyone wants to revisit the exports-condition approach, that's a separate ticket.Related