Skip to content

fix(docsite): render Recharts in the playground - #6263

Merged
ernestt merged 2 commits into
mainfrom
docsite-playground-recharts
Sep 15, 2026
Merged

ernestt merged 2 commits into
mainfrom
docsite-playground-recharts

Conversation

@ernestt

@ernestt ernestt commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Every chart in the playground rendered as nothing. Found while looking at #6065, but it is not that PR's doing — seven templates on main draw with Recharts, so this was every dashboard.

Why it was silent

The playground does not bundle templates. It transpiles the source in-browser and evaluates it with a CommonJS require that resolves against the generated scope map in apps/docsite/src/generated/playground-scope.ts. That map had 130 keys — React, StyleX, every core component, the themes, hooks, lucide-react, Heroicons, a next/image stub — and no recharts. It was not a docsite dependency either.

An unresolved module does not throw. The runner returns a proxy whose every export is () => null:

// Unknown module — return placeholders that render nothing.
return new Proxy({__esModule: true}, {
  get(_target, prop) { /* ... */ return () => null; },
});

So ResponsiveContainer, AreaChart, Area and friends all became components rendering nothing, while the legends and axis labels around them painted normally, under a status pill reading Build finished. Nothing in the UI, the console, or CI said a word.

Before / after

Same server, same template, only the scope entry differs.

Before After

In the before shot, "Active users" shows its All Users / Desktop / Mobile legend over empty space and the four stat cards have no sparklines.

Measured inside the preview iframe:

Before After
nodes rendered 465 756
.recharts-* wrappers 0 21
chart surfaces 0 7
drawn paths 0 17
SVG elements 18 (icons only) 25
render error none none

dashboard-scorecard behaves the same: 12 wrappers, 4 surfaces, 12 paths.

Changes

recharts joins the docsite dependencies and the scope map, next to the icon libraries. It was already in the lockfile via apps/sandbox, so the lockfile gains three lines.

The runner warns once per unresolved module. The fallback has to stay forgiving — playground users may import anything, and hard-failing every stray import would make the editor unusable — but there is no reason for it to be silent. Captured from the browser console with the entry removed:

[playground] "recharts" is not in the preview scope — its exports will render
nothing. Add it in apps/docsite/scripts/generate-scope.mjs.

playground-scope.test.ts gains a check that every bare import in the page templates resolves. The existing assertions are a hand-maintained allowlist, and an allowlist only covers what someone thought to add — nothing asked the templates what they actually need. It parses real import statements only, and matches case-insensitively because the runner lowercases both sides when resolving. Removing the scope entry makes it fail with exactly ['recharts'], which is to say it would have caught this.

Not fixed here

recharts has no entry in the playground type bundle, so Monaco underlines the import. lucide-react has the same gap today — the bundle covers core, React, StyleX and Heroicons only. It is an editor-only wart, separate from whether the chart draws, and worth its own change.

Gates

Docsite suite 34 files / 498 tests, tsc --noEmit 0 errors, eslint clean, and check:sync, check:use-client, check:portable-scripts, check:repo, check:changesets all pass.

Every chart in the playground rendered as nothing. The preview does not
bundle templates — it transpiles the source in-browser and evaluates it
with a require that resolves against the generated scope map, and that
map had no recharts entry. Unresolved modules do not throw: the runner
returns a proxy whose every export is `() => null`, so the charts
vanished while the legends and axis labels around them painted normally,
under a status pill reading "Build finished".

Seven templates on main draw with Recharts, so this was every dashboard.

Three changes:

- recharts joins the docsite dependencies and the scope map, next to the
  icon libraries. It was already in the lockfile via apps/sandbox, so the
  lockfile gains three lines.
- The runner now warns once per unresolved module. The fallback has to
  stay forgiving, since playground users may import anything, but there
  is no reason for it to be silent.
- playground-scope.test.ts gains a check that every bare import in the
  page templates resolves. The existing assertions are an allowlist, and
  an allowlist only covers what someone thought to add — nothing here
  asked the templates what they need. Removing the scope entry makes it
  fail with exactly ['recharts'].

Verified against a running playground. dashboard goes from 465 nodes and
zero .recharts-* elements to 756 nodes, 21 chart wrappers, 7 surfaces and
17 drawn paths, with no render error either way.

Not fixed here: recharts has no entry in the playground type bundle, so
Monaco underlines the import. lucide-react has the same gap today; it is
an editor-only wart and separate from whether the chart draws.

Co-authored-by: Cursor <[email protected]>
@vercel

vercel Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 12, 2026 5:14am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 12, 2026
@astracat-bot

astracat-bot Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Sep 12, 2026, 5:20 AM UTC

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run completed, but its trusted analysis is unavailable. Preview links are not shown.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this fixes the silent dashboard failure cleanly. I verified seven rendered chart surfaces, unchanged unknown-import fallback behavior, one warning, and green CI.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks—the merged base now supplies the Recharts runtime, and this head adds broad regression coverage plus one-shot diagnostics cleanly. I reverified seven chart surfaces and green CI.

This branch was successfully deployed

1 active deployment
Preview — 16ba615d Deployed Sep 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant