fix: pre-deploy local build check + client/server boundary rules#227
Merged
Conversation
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>
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
Fixes #226 — client bundle contamination not caught before deploy.
Three-layer prevention:
deploy-to-staging.js: Runsturbo run build(ornext 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/cliententry 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/clientexport, andimport 'server-only'on database modules.Context
Irish Planning's
precedentio-search-mvpmilestone hit this:search.tsre-exported DB functions fromsearch-queries.ts,client.tsimported fromsearch.ts, webpack pulled the entirepgdependency chain into the client bundle → 9 failed deploys across 2 escalation cycles before it was manually resolved.Test plan
turbo.json)next buildfor non-turbo projects🤖 Generated with Claude Code