perf: split lightweight state-index out of the registry (drop ~26KB from client routes) - #7
Conversation
content/state-registry.ts (~26KB gzipped) shipped to the client via every
component that imports it. Many only need {code, name, emoji} for dropdowns
and labels. Add a standalone generated state-index.ts (1.4KB gzipped) so those
components can stay off the full registry. Generated by scripts/gen-state-index.ts;
state-index.test.ts asserts it never drifts from the registry.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
8 client components that only read {code, name, emoji} now import the
lightweight state-index instead of the full STATE_REGISTRY, so their routes
(the wizard flow, wizard/summary, capability-statement, gc-directory) drop
the ~26KB registry from the client bundle. Consumers that render full
StateData (home tax info, estimator calc, starter-kit, comparison, unions)
intentionally keep the registry — typecheck enforces the split.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughA new codegen script ( ChangesSTATE_INDEX Codegen and Consumer Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 350d2f1942
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import type { StateCode } from "@/content/phases"; | ||
| import type { WizardProgress } from "@/lib/types/wizard"; | ||
| import { STATE_REGISTRY } from "@/content/state-registry"; | ||
| import { STATE_INDEX } from "@/content/state-index"; |
There was a problem hiding this comment.
Stop counting wizard pages as registry-free
In the wizard client bundle, this new index import does not remove the full registry: the same component imports getPhaseContent from @/content/phases, and content/phases.ts imports STATE_REGISTRY to generate phase content. Because app/wizard/[phase]/[step]/page.tsx renders this client component, the wizard flow still ships the registry despite this change; split the phase definitions/light metadata from the registry-backed generators before treating this route as lightweight.
Useful? React with 👍 / 👎.
Highest-value remaining Phase 3 perf item from the roadmap (
docs/plans/2026-06-17-001).Problem
content/state-registry.ts(2860 lines, ~26KB gzipped) was imported by 17"use client"components, so the full regulatory dataset shipped in the client bundle of every route that touched it — including routes that only needed a state's name/emoji for a dropdown or label.Fix
content/state-index.ts— a standalone{code, name, emoji}index (1.4KB gzipped), produced byscripts/gen-state-index.ts. Standalone (not derived from the registry at runtime) so importing it doesn't pull the registry back in.content/state-index.test.tsasserts the index never drifts from the registry (same codes, matching name/emoji) — adding a state to the registry without regenerating fails CI.Classification was compiler-enforced, not guessed
Repointed candidates, then let
tscreject any that actually needed fullStateData. It caughtapp/page.tsx(renders state tax fields) — reverted to the registry. Consumers that genuinely render full data (home tax info, estimator calc, starter-kit, comparison-table/summary, unions) intentionally stay on the registry.Verification
tsc --noEmitclean · lint 0 errors (22 warnings) · production build compiles.Not done (future, deliberate)
/, /estimator, /compare, /starter-kit, /unions still carry the registry because they render full per-state data client-side. Moving those to server-component data loading (pass only what's needed as props) is the next-tier win — a larger RSC refactor for its own PR.🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Tests