Skip to content

fix: pre-deploy local build check + client/server boundary rules#227

Merged
gregario merged 1 commit into
mainfrom
fix/pre-deploy-build-check-226
May 5, 2026
Merged

fix: pre-deploy local build check + client/server boundary rules#227
gregario merged 1 commit into
mainfrom
fix/pre-deploy-build-check-226

Conversation

@gregario

@gregario gregario commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #226 — client bundle contamination not caught before deploy.

Three-layer prevention:

  • deploy-to-staging.js: Runs turbo run build (or next build) locally before pushing to Vercel. Catches webpack errors, TS errors, and static generation failures in seconds instead of burning 3 remote retries × 30s delay each. If local build fails, deploy is aborted with a clear error message.

  • 01-building.md (guardrail): Rule that building phases must never add re-exports from server-only modules to files reachable from /client entry points. Webpack bundles the entire transitive graph — it cannot tree-shake re-exports.

  • 00-foundation-building.md (scaffolding): When creating shared workspace packages for Next.js App Router, enforce from day one: sideEffects: false, separate /client export, and import 'server-only' on database modules.

Context

Irish Planning's precedentio-search-mvp milestone hit this: search.ts re-exported DB functions from search-queries.ts, client.ts imported from search.ts, webpack pulled the entire pg dependency chain into the client bundle → 9 failed deploys across 2 escalation cycles before it was manually resolved.

Test plan

  • Building prompt behavioral tests pass (33/33)
  • Foundation prompt tests pass
  • Full suite: 2,010 pass, 0 regressions (1 pre-existing flaky instance-lock test)
  • Pre-deploy check detects turborepo projects (checks for turbo.json)
  • Pre-deploy check falls back to next build for non-turbo projects

🤖 Generated with Claude Code

Three-layer prevention for client bundle contamination in Next.js projects:

1. deploy-to-staging.js: run local build (turbo run build or next build)
   before pushing to Vercel. Catches webpack/TS errors in seconds instead
   of burning 3 remote retries × 30s each.

2. 01-building.md: guardrail rule — never add re-exports from server-only
   modules to files reachable from /client entry points. Webpack bundles
   the entire transitive graph of "use client" modules.

3. 00-foundation-building.md: when scaffolding shared workspace packages
   for Next.js App Router, enforce sideEffects:false, separate /client
   export, and import 'server-only' on DB modules from day one.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gregario gregario merged commit aa5f92f into main May 5, 2026
1 of 3 checks passed
@gregario gregario deleted the fix/pre-deploy-build-check-226 branch May 5, 2026 11:58
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.

bug: client bundle contamination not caught before deploy (Next.js barrel re-exports)

1 participant