Skip to content

Fix chart catalog data imports in browser previews - #1240

Merged
tannerlinsley merged 1 commit into
mainfrom
taren/fix-charts-catalog-data
Sep 9, 2026
Merged

Fix chart catalog data imports in browser previews#1240
tannerlinsley merged 1 commit into
mainfrom
taren/fix-charts-catalog-data

Conversation

@tannerlinsley

@tannerlinsley tannerlinsley commented Sep 9, 2026

Copy link
Copy Markdown
Member

The shadcn multiple-bar example stays blank on tanstack.com because its revision-pinned esm.sh GitHub data import times out before React mounts. Fetch dataset source and nested dependencies with the existing catalog source closure, then compile local data aliases with the example. Keep the source revision pinned and preserve authored imports.

Allow a single file to use the existing 1 MiB project budget so the largest catalog dataset still saves and shares. The total snapshot limit remains 1 MiB.

Validation:

  • Full pnpm test, including TypeScript, lint, and unit tests.
  • Browser verification using the real workspace compiler and published Charts 0.16.2 reaches ready and renders all 12 bars without console errors.
  • All 188 catalog source closures resolve; the largest serialized project is 874,707 bytes, within the existing budget.

Summary by CodeRabbit

  • New Features

    • Builder project snapshots now support individual files up to 1 MiB, with a total snapshot limit of 1 MiB.
    • Charts catalog examples now support local demo-data imports for more reliable example loading.
  • Bug Fixes

    • Improved workspace import resolution for exact and nested mappings.
    • Added safeguards to prevent chart example imports from accessing files outside their permitted directories.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 57cbb358-f934-4910-9ebd-e701080e96ad

📥 Commits

Reviewing files that changed from the base of the PR and between 7739cfa and dd15492.

📒 Files selected for processing (10)
  • src/utils/builder-project-snapshot.ts
  • src/utils/charts-catalog-example.ts
  • src/utils/charts-catalog.server.ts
  • src/utils/example-esbuild.client.ts
  • src/utils/example-workspace.ts
  • tests/builder-project-snapshot-storage.test.ts
  • tests/builder-project-sync.test.ts
  • tests/charts-catalog-example.test.ts
  • tests/charts-catalog-source.test.ts
  • tests/example-workspace.test.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change raises builder snapshot limits and adds a total budget. It also maps chart catalog data imports to the local workspace, resolves mapped imports during builds, and rejects imports that escape allowed directories.

Changes

Builder snapshot limits

Layer / File(s) Summary
Snapshot size limits and validation
src/utils/builder-project-snapshot.ts, tests/builder-project-snapshot-storage.test.ts, tests/builder-project-sync.test.ts
The per-file limit increases to 1 MiB. Snapshot parsing now tests the 1 MiB total budget and updated text and binary file limits.

Catalog workspace imports

Layer / File(s) Summary
Catalog import mappings
src/utils/charts-catalog-example.ts, tests/charts-catalog-example.test.ts
Chart demo-data imports now map to /packages/charts-demo-data/src/ instead of revision-pinned remote URLs.
Workspace import resolution
src/utils/example-workspace.ts, src/utils/example-esbuild.client.ts, tests/example-workspace.test.ts
Workspace imports support exact and longest-prefix matches. The esbuild plugin resolves mapped paths before externalizing bare specifiers or resolving relative paths.
Catalog source loading and bounds checks
src/utils/charts-catalog.server.ts, tests/charts-catalog-source.test.ts
Catalog loading recognizes both data prefixes, fetches local data dependencies, and rejects imports that leave the allowed directory.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to dd154

Catalog previews now load local revision-pinned data dependencies and snapshots allow files up to the retained 1 MiB total budget. Current coverage indicates no merge-blocking risk.

Sequence Diagram(s)

sequenceDiagram
  participant CatalogLoader as getChartsCatalogExample
  participant ModuleResolver as resolveCatalogExampleModule
  participant GitSource as Git source
  participant Workspace as Example workspace
  CatalogLoader->>ModuleResolver: resolve data-prefixed module
  ModuleResolver->>ModuleResolver: validate allowed directory
  ModuleResolver->>GitSource: fetch resolved data module
  GitSource-->>CatalogLoader: return module source
  CatalogLoader->>Workspace: add data module and dependencies
Loading

Suggested reviewers: abeuty

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: fixing chart catalog data imports in browser previews.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch taren/fix-charts-catalog-data

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tannerlinsley
tannerlinsley marked this pull request as ready for review September 9, 2026 16:06
@tannerlinsley
tannerlinsley requested a review from a team September 9, 2026 16:06
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com dd15492 Commit Preview URL

Branch Preview URL
Sep 09 2026, 04:07 PM

@tannerlinsley
tannerlinsley merged commit ec2f9c7 into main Sep 9, 2026
7 checks passed
@tannerlinsley
tannerlinsley deleted the taren/fix-charts-catalog-data branch September 9, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant