Moves the app to TanStack Start with prerendering

Every page is now built as HTML from sitePages.ts, with a catch-all route for
404.html. Hooks that read the browser during render are safe for prerendering.
The script step that keeps the CSP intact follows, so this build still has
inline scripts and is not deployable yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 17:58:54 +01:00
co-authored by Claude Opus 5.5
parent 65c850e949
commit c1e90f0768
33 changed files with 746 additions and 269 deletions
@@ -162,7 +162,7 @@ PBT-02 (round-trip): P3, P10. PBT-03 (invariant): P1, P2, P5, P6, P8, P14, P16.
The unknowns that can invalidate the design come first. Steps 3 to 6 prove Start, `getRouter`, `shellComponent`, `src/client.tsx` and the test harness on the real app before the mechanical conversions. If an unknown fails, apply the STOP rule: report to the main session; do not improvise.
### Step 3: Remove what makes prerendering throw [ ]
### Step 3: Remove what makes prerendering throw [x]
- Executor: Sonnet.
- Implements: BR-HYD-02, 03, 04, 05, 07, 08 (media and breakpoint part), 09, 15; BR-MON-03; FR-PR-05, 08.
@@ -177,8 +177,9 @@ The unknowns that can invalidate the design come first. Steps 3 to 6 prove Start
- `web/src/components/Analytics/UmamiAnalytics.tsx`: `hostname` prop optional without a default; the effect uses `hostname ?? window.location.hostname`.
- Done when: no `ssr: false` remains in `web/src` (`grep -rn "ssr: false" web/src` empty), `pnpm exec tsc --noEmit` is clean, `pnpm lint` is clean, and **CP0**: `pnpm test` passes without test changes. If an old test fails because it relied on first-render media values, fix the test per BR-TST-02 (wrap in `act`/`waitFor`) and list the changed tests in the Record line.
- Record: a line in `code/verification-log.md` is not needed yet; list changed old tests (if any) under the step in this plan.
- Record (2026-10-31): CP0 green, 113 files, 888 tests. Changed old tests: `usePageLoaded.test.tsx` and `DeferredImage.test.tsx` (the mocked `readyState` must become `complete` when the `load` event fires, as in a browser, because the hook now reads a store snapshot); `useReveal.test.tsx` (first render assumes no reduced motion, so an observer starts and is disconnected at once; test expects all observers disconnected instead of none created).
### Step 4: Start setup and first prerender of the real app (V1, V3, V5, V6, V7, V11, V13, V15, V17) [ ]
### Step 4: Start setup and first prerender of the real app (V1, V3, V5, V6, V7, V11, V13, V15, V17) [x]
- Executor: Sonnet.
- Implements: BR-BLD-02, 03, 05, 06, 07, 08, 09 (plugin part), 10 (n/a here), 11; BR-ENT-01 to 05; BR-404-01, 02; BR-MON-01; D1, D5, D13; FR-PR-01, 02, 03, 04, 08, 14 (route part); NFR-PR-Q-04, SEC-02.
@@ -196,8 +197,9 @@ The unknowns that can invalidate the design come first. Steps 3 to 6 prove Start
11. Run `pnpm exec tsc --noEmit`, then `pnpm build`. Inspect `web/dist/client`: list all files; the HTML set must be exactly the 11 pages plus `404.html` (`index.html`, `over-mij.html`, `soorten-fotoshoots.html`, `soorten-fotoshoots/<5 shoots>.html`, `contact.html`, `privacyverklaring.html`, `portfolio.html`, `404.html`); `sitemap.xml` exists once in `dist/client`; for every HTML file list its inline `<script>` elements (position, attributes, first 80 characters of the body, body length) and whether any contains `<!--`, has `async`/`defer`, or is a module with relative imports (BR-SCR-05); check `/over-mij.html` for exactly one `<title>`, one `description`, one `canonical`, no `data-fallback`; grep the whole `dist/client` for the string `info@andreaslop.nl` (expected to appear until Step 17; note where) and for the repository path (V13).
- Done when: **CP1 part 1**: `pnpm build` succeeds (prerender completed for all 12 files) and the verification log rows above are filled with evidence. A prerender error caused by something other than Step 3's list (for example a component that throws on the server) is fixed only if the fix is inside the rules of business-rules.md BR-HYD; otherwise STOP.
- Record: `code/verification-log.md` rows V1, V3, V5, V6, V7, V11, V13, V15, V17; add the resolved package versions under the log's header.
- Record (2026-10-31): done, see the log (versions, zod override, router bump, `RoutePath` excludes `/$`, `@tanstack/router-plugin` removed).
### Step 5: Test harness for the new router (V2) [ ]
### Step 5: Test harness for the new router (V2) [x]
- Executor: Sonnet.
- Implements: BR-TST-01, 02; D12; NFR-PR-Q-01; V2.
@@ -208,8 +210,9 @@ The unknowns that can invalidate the design come first. Steps 3 to 6 prove Start
4. Run `pnpm test`.
- Done when: **CP1**: `pnpm build` green and `pnpm test` green (all pre-existing tests pass; list tests you had to change, with the reason, in the Record line).
- Record: verification log V2 (what happened, which variant); changed tests.
- Record (2026-10-31): CP1 green (`pnpm build` 12 HTML files; `pnpm test` 113 files, 888 tests). V2: test shell variant in `renderApp`. Changed in this step: `app.test.tsx` register test ignores `/$`. `routeTree.gen.ts` diff: only the `/$` route and Start's `Register` declaration.
### Step 6: Proof report and decision to continue [ ]
### Step 6: Proof report and decision to continue [x]
- Executor: Sonnet.
- Do: write `aidlc-docs/features/prerendering/construction/start-migration/code/proof-report.md` (max one page): per V1, V2, V3, V5, V6, V7 the outcome in one or two sentences with evidence; the list of inline scripts per page as found; the resolved dependency versions; any deviation from the design (none expected).