[READ-ONLY] Mirror of https://github.com/Rowan-Paul/vodcreator. vodcreator.rowanpaulflynn.com

fix: keep @trpc/server out of the client bundle main

The site crashed in the browser with "You're trying to use @trpc/server in a non-server environment" after the Next.js 16.1.6 -> 16.3.3 upgrade. src/trpc/react.tsx ("use client") imported the router type as `import { type AppRouter } from "@/server/api/root"`. With verbatimModuleSyntax enabled, only `import type { ... } from` is erased; the inline form must be preserved as a bare side-effect import. Next 16.1's bundler elided it anyway, 16.3 honours the flag correctly, so the upgrade exposed a latent bug rather than introducing one. The preserved import pulled the whole server graph into the client chunk: root.ts -> api/trpc.ts -> initTRPC(...).create() at module scope. tRPC v11 guards create() with an isServer check, so the chunk threw on load and the page never hydrated. The Twitch service and NextAuth config shipped too; secret values did not, since Next only inlines NEXT_PUBLIC_*. - use `import type` for both type-only imports in src/trpc/react.tsx - add `import "server-only"` to src/server/api/trpc.ts so this mistake is a build error with an import trace, not a production crash - record the boundary decision in docs/adr/0001-trpc-server-boundary.md - fix the AGENTS.md import guidance that recommended the inline form Verified: `grep -rl "non-server environment" .next/static/` returns nothing after a build (it matched a chunk before). build and check both pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>


Author Rowan-Paul Co-author Claude Opus 5 (1M context) Date Commit Parent c280c53d
+65 -3
4 changed files
+65 -3
4 changed files