Problem
Three avoidable bundle costs on every dashboard page:
hooks/use-realtime-route-refresh.ts:4 imports createClient from the Supabase client module at the top level. The Neon branch at line 100 is a runtime check, so the import is never tree-shaken. That pulls @supabase/ssr and realtime-js into nine production client chunks, about 450 KB across the two largest, and all of it is dead when the data backend is Neon (which is every environment in .env.example, docker-compose.yml, playwright.config.ts and CI).
components/ai-elements/code-block.tsx:30 statically imports createHighlighter from shiki, a 372 KB chunk, in a client component that is not behind next/dynamic.
next.config.mjs:75 lists only iconoir-react in optimizePackageImports. lucide-react is imported in 32 component files and is not listed.
Fix
- In
use-realtime-route-refresh.ts, move the Supabase import inside the non-Neon branch as await import("@/lib/supabase/client"). Better: since production is Neon, delete the Supabase branch entirely if the realtime route refresh has a Neon implementation. Check with the maintainer before deleting.
- In
code-block.tsx, load the highlighter with await import("shiki") inside the effect that creates it, and render plain preformatted text until it resolves.
- Add
"lucide-react" to optimizePackageImports.
Exit criteria
Out of scope
Converting app/(dashboard)/layout.tsx from a client component to a server component. Larger change, separate issue.
https://claude.ai/code/session_01SQ4nS96XYRztd5w9QkubPf
Problem
Three avoidable bundle costs on every dashboard page:
hooks/use-realtime-route-refresh.ts:4importscreateClientfrom the Supabase client module at the top level. The Neon branch at line 100 is a runtime check, so the import is never tree-shaken. That pulls@supabase/ssrandrealtime-jsinto nine production client chunks, about 450 KB across the two largest, and all of it is dead when the data backend is Neon (which is every environment in.env.example,docker-compose.yml,playwright.config.tsand CI).components/ai-elements/code-block.tsx:30statically importscreateHighlighterfromshiki, a 372 KB chunk, in a client component that is not behindnext/dynamic.next.config.mjs:75lists onlyiconoir-reactinoptimizePackageImports.lucide-reactis imported in 32 component files and is not listed.Fix
use-realtime-route-refresh.ts, move the Supabase import inside the non-Neon branch asawait import("@/lib/supabase/client"). Better: since production is Neon, delete the Supabase branch entirely if the realtime route refresh has a Neon implementation. Check with the maintainer before deleting.code-block.tsx, load the highlighter withawait import("shiki")inside the effect that creates it, and render plain preformatted text until it resolves."lucide-react"tooptimizePackageImports.Exit criteria
pnpm build, thengrep -rl "postgres_changes" .next/static/chunksreturns nothing whenNEXT_PUBLIC_MOGPLEX_DATA_BACKEND=neon./control(check the build output or the Network tab on first load).pnpm lint,pnpm typecheck,pnpm testpass.Out of scope
Converting
app/(dashboard)/layout.tsxfrom a client component to a server component. Larger change, separate issue.https://claude.ai/code/session_01SQ4nS96XYRztd5w9QkubPf