You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(docs): live-render chart pages via separate rcs-charts bundle
The chart docs pages were the last surface still falling back to a
static placeholder. They now render live in the browser, same as the
core component pages, completing the "React-only docs" goal of this
PR (no hand-written HTML left).
Approach — separate IIFE bundle:
- New scripts/bundle-entry-charts.ts re-exports `src/charts/*` plus
React + ReactDOM's createRoot. esbuild rolls it into
rcs-charts.iife.js as `window.RCSCharts`.
- build-site.mjs runs a second esbuild pass for this entry. Heavy
WebGL peer deps (@deck.gl/core, @deck.gl/layers, d3-force) are
marked --external; the chart components already have canvas2d /
SVG fallback paths when the WebGL handoff fails to import. That
keeps the chart bundle at ~794 KB instead of ~2.3 MB.
- The chart bundle ships its own React. Because chart demos render
standalone in their own createRoot — never nested inside the main
bundle's React tree — the "two React instances" footgun does not
apply, and they read theme via CSS custom properties (not
Context).
- esbuild also emits rcs-charts.iife.css (~1.6 KB) from the dynamic
`await import("uplot/dist/uPlot.min.css")` in Chart.tsx. The
chart-page <head> includes it.
build-docs.mjs:
- runner.js now exposes both `runExample` (uses window.RCS) and
`runChartExample` (uses window.RCSCharts), refactored to share a
`transformExample` helper. Each runner verifies its bundle is
loaded and surfaces the failure inline.
- renderComponentPage picks the right runner via a `runFn` variable
and conditionally injects `<script src="../bundle/rcs-charts.iife.js">`
+ the chart CSS into chart pages only.
- Static chart placeholder removed: chart pages now use the same
`<div class="demo-render">` and a hidden code panel as core pages.
- Dead .demo-render--static / .demo-static-note CSS rules dropped.
Verified: pnpm typecheck clean, Sparkline unit tests still pass,
pnpm build:site emits both bundles (rcs.iife.js 236 KB +
rcs-charts.iife.js 794 KB) and 58 component pages. Spot-checked
generated HTML: /docs/Chart/ pulls both bundles + the chart CSS and
calls runChartExample; /docs/Button/ pulls only the main bundle and
calls runExample.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments