Skip to content

fix(dev): rebuild shared workspaces before npm run dev (#968)#970

Open
jakebromberg wants to merge 1 commit into
mainfrom
fix/968-predev-shared-build
Open

fix(dev): rebuild shared workspaces before npm run dev (#968)#970
jakebromberg wants to merge 1 commit into
mainfrom
fix/968-predev-shared-build

Conversation

@jakebromberg
Copy link
Copy Markdown
Member

Summary

Adds an npm lifecycle predev script that rebuilds @wxyc/database + @wxyc/authentication before npm run dev, so a fresh clone or any pull that touches shared/database/src/schema.ts doesn'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 object deep inside drizzle-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 the dist/index.js mtime predated the schema commit.

apps/backend/tsup --watch rebuilds its own sources but doesn't follow workspace dep dists; predev covers the gap.

Change

+ "predev": "npm run build --workspace=@wxyc/database --workspace=@wxyc/authentication",

Mirrors the existing lint:prebuild shape — same workspaces, same npm run build invocation. CLAUDE.md "Running locally" gets a one-paragraph note explaining the why.

Test plan

  • Wiped shared/database/dist + shared/authentication/dist; ran npm run predev. Both rebuilt successfully (DTS clean, ~1s wall clock). Verified flowsheet.track_position (the symbol whose absence trips the original bug) is present in the regenerated dist/index.js.
  • npm run dev now chains predev first per npm lifecycle convention. Already runs dotenvx run -f .env -- concurrently for the actual dev startup; predev runs in a separate shell invocation so dotenvx wrapping is irrelevant.
  • No CI changes — lint:prebuild already covers the shared-workspace rebuild for lint/typecheck/build CI jobs, so CI is untouched.

Notes

  • Why not --workspaces --if-present? Would also build apps/* and jobs/*, which tsup --watch in dev:backend / dev:auth already handles. ~1s vs ~5s startup delta isn't a lot, but the explicit-list approach matches lint:prebuild and is self-documenting.
  • Why not switch the exports map to point at ./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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm run dev silently serves stale @wxyc/database when shared/database/dist is out of date

1 participant