perf(docs): lazy-load search and highlight code at build time
Draft
FA
2mo ago+1735+1735+0123456789012345678901234567890123456789-37-37-01234567890123456789
Summary
- lazy-load the Inkeep docs search widget while preserving its keyboard shortcut, accessible labels, and pixel-stable handoff
- discover literal docs code blocks during an automatic production prepass, highlight them once with pinned Shiki 3.3.0, and embed the generated HTML in the final prerendered pages
- keep the existing client Shiki component in development and for genuinely dynamic code values
- remove prose-only Markdown components from the introduction route so they do not pull a second syntax-highlighting runtime into that page
Production builds still use the normal reflex export path and normal eager React hydration. There is no performance selector, deferred-hydration bootloader, event replay, or Lighthouse matrix in this PR.
Build behavior
StaticShikiPlugin owns the production flow:
- Run a guarded discovery compile to collect literal code/theme/language requests.
- Write a deterministic, content-addressed manifest.
- Install the checked-in frozen Shiki runtime and generate every highlighted block in one JavaScript process.
- Run the normal production render against that cache, failing on missing, stale, or mismatched entries.
- Remove the temporary manifest, cache, and runtime after the build.
Dynamic code blocks and local development retain the existing client-side behavior.
Validation
- standard frontend-only
reflex exportcompleted successfully with no wrapper command or feature flags - production discovery generated 1,232 cached blocks; the introduction artifact contains nine static Shiki blocks and its route module has no Shiki or React Syntax Highlighter import
- browser smoke test confirmed correct dark-theme token colors, working hydrated tabs, and no hydration/page errors
383 passed, 1 skippedin the docs test suite24 passedin the focused static-Shiki regression suiteuv run ruff check .uv run ruff format --check .uv run pyright reflex testsuv run pre-commit run --all-files- built the
reflex-site-sharedwheel and verified the generator plus frozen runtime files are included - changelog fragment check passes
Tradeoffs
- production docs builds perform one additional page-evaluation pass before the final render
- only literal code is statically highlighted; dynamic code continues to use the client component