Files
AndreaSlopFotografie/aidlc-docs/features/prerendering/inception/application-design/services.md
T
SluijsensandClaude Opus 5.5 65c850e949 Adds the prerendering requirements, design and baseline
Records the requirements, execution plan, application design, the first unit's
functional design and code generation plan, and the baseline on master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 17:41:12 +01:00

49 lines
2.1 KiB
Markdown

# Services: prerendering
The site has no runtime services. The orchestration in this feature happens at build time and once in the browser.
## Build pipeline
`pnpm build` runs in this order:
1. `tsc`
2. `vite build`: Start builds client and server, runs the server locally and prerenders each page to `dist/client`
3. `node config/externalizeInlineScripts.ts`: moves inline scripts and guards the result
The server output in `dist/server` exists only during the build and is never deployed.
## Page load in the browser
```mermaid
sequenceDiagram
box rgba(246,224,94,0.4) Browser
participant V as Visitor
participant R as React
end
box rgba(99,179,237,0.4) Static host
participant H as nginx or IIS
end
V->>H: Request page
H-->>V: Complete HTML with styles
V->>H: Request first photo through preload
H-->>V: First photo
V->>H: Request scripts at end of body
H-->>V: Moved scripts and main bundle
R->>R: Hydrate with the same first render as the HTML
R->>R: Apply browser values such as search, breakpoints and fade-in
```
Text alternative: the host returns complete HTML, the first photo is preloaded, scripts load at the end of the body, React hydrates with the same first render as the HTML, and only then applies values that exist in the browser.
## Pure functions and testable properties (PBT-01)
Confirmed per unit in Functional Design and Infrastructure Design.
| Function | Category | Property |
|---|---|---|
| `externalizeInlineScripts` | Invariant | Script order is preserved; all non-script content is unchanged |
| `externalizeInlineScripts` | Round-trip | Putting each moved body back at its reference restores the original HTML, apart from the tag's attributes |
| `externalizeInlineScripts` | Idempotence | Applying it twice gives the result of applying it once |
| `externalizeInlineScripts`, `findExecutableInlineScripts` | Invariant | Data blocks stay inline; no executable inline script remains in the result |
| `resolveRequest` | Invariant | Every path gives a file, a 404 or one redirect; a path never leaves the client directory |