Repository navigation
fix(docsite): render Recharts in the playground - #6263
Merged
Merged
Conversation
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]>
ernestt
requested review from
cixzhang,
imdreamrunner and
josephfarina
as code owners
September 12, 2026 00:22
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
AI review status for this pull request.
|
Contributor
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every chart in the playground rendered as nothing. Found while looking at #6065, but it is not that PR's doing — seven templates on
maindraw 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
requirethat resolves against the generated scope map inapps/docsite/src/generated/playground-scope.ts. That map had 130 keys — React, StyleX, every core component, the themes, hooks,lucide-react, Heroicons, anext/imagestub — and norecharts. It was not a docsite dependency either.An unresolved module does not throw. The runner returns a proxy whose every export is
() => null:So
ResponsiveContainer,AreaChart,Areaand 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.
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:
.recharts-*wrappersdashboard-scorecardbehaves the same: 12 wrappers, 4 surfaces, 12 paths.Changes
rechartsjoins the docsite dependencies and the scope map, next to the icon libraries. It was already in the lockfile viaapps/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-scope.test.tsgains 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
rechartshas no entry in the playground type bundle, so Monaco underlines the import.lucide-reacthas 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 --noEmit0 errors, eslint clean, andcheck:sync,check:use-client,check:portable-scripts,check:repo,check:changesetsall pass.