Repository navigation
Load only the chart types a page draws - #684
Merged
Merged
Conversation
exploreda/chart-core exports Chart, ChartSettings, and registerCharts with no chart type registered; exploreda/chart is that entry plus every type. All 27 types now have an exploreda/charts/<type> entry; nine were missing. CHART_IMPORTS maps each type to its entry and export, and a test checks it against entries.json and the real exports. A chart whose type isn't registered shows the two lines to add. In the example app, a page with a bar chart and a scatter plot loads 1,422 KB up front through chart-core against 2,987 KB through chart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
exploreda/chart no longer registers every type when it loads. Each type's definition is its own chunk, loaded the first time a chart of that type draws, while the chart holds its box. A settings panel, once open, and a Dashboard text config load every type, since they can name any. chart-core keeps explicit, up-front registration. The example app's first page, 34 charts over all 27 types, now loads 1,283 KB up front, against 2,987 KB before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A page that uses explorEDA's standalone charts now downloads only the chart types it draws.
exploreda/chartloads each type's code the first time a chart of that type draws. The host writes no setup: the sameimport { Chart } from "exploreda/chart"now loads less than half the JavaScript up front. For hosts that want no request before the first draw, the newexploreda/chart-coreregisters chosen types up front.What you'll see
exploreda/chart, the default.exploreda/chart-core, for up-front registration.registerChartschecks each definition against its own settings type.exploreda/charts/<type>import. Nine were missing.Proof
pnpm build && pnpm sizesinexamples/standalone-chartscounts each page's entry chunk plus its static imports. React is included in both counts:index.html: 34 charts over all 27 types, settings, a text configexploreda/chartlean.html: a bar chart and a scatter plotexploreda/chart-coreOn
index.html, the rest (2,756 KB) loads after first paint. A check of the production build at 1280 px found all 27 type cards drawn, no chart still loading, no alerts, and no console errors. The settings panel's Chart Type list offered all 27 types.lean.html: two registered types draw. The third card asks for a line chart that was never registered, and names the import to add.The docs table of each chart type, its import path, and its definition name.
Tests:
loading.test.tsx, in a fresh module graph with nothing registered:baris registered andmapis not."nonsense" isn't a chart type.core.test.tsx: the exact import hint, drawing afterregisterCharts, and that everyCHART_IMPORTSentry exists inentries.jsonand really exports its definition.Limits
chart-coreavoids that wait.🤖 Generated with Claude Code