Skip to content

feat(core, ui-react)!: block renderers move out of blockTypes into the createRoutes renderers module (R2) - #31

Merged
jherr merged 1 commit into
mainfrom
cursor/renderer-binding-d21e
Nov 6, 2026
Merged

jherr merged 1 commit into
mainfrom
cursor/renderer-binding-d21e

Conversation

@jherr

@jherr jherr commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Implements cms-refactor-plan.md § Track R2 for block renderers: item 9 ("Agnostic data model, framework-specific renderers"), item 10's props-over-providers rule, and decided questions 21 and 22. Field inputs follow in a separate PR stacked on this one, as Q22 asks.

Merge chain: step 7 of 24. Base: main. Merge it right after #28. The branch is main 3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit a50f376 (tree 2647b7e).

What

  • Block types are data only in @tanstack/cms-core: BlockType is { type, label, fields }. defineBlock, defineCms and plugin blockTypes throw for a block type that still has a component, and the error names the fix.

  • A renderers module (Q21):

    • defineRenderers({ blocks }) comes from @tanstack/cms-ui-react.
    • The app names the module in createRoutes(definition, { renderers: '../cms.renderers.tsx' }). That's a path, never an import, so vite.config.ts stays React-free.
    • The tanstackCms() plugin's load hook serves the package's src/app-renderers.ts as that module, and every package route imports it.
  • Resolution order in BlockView:

    1. the renderers prop;
    2. the bound module;
    3. the built-in renderers;
    4. GenericBlockView.

    Lookups are own-property only.

  • Bespoke code passes renderers as props. BlocksView, BlockView, InteractivePageContent and InteractiveDocument take renderers.

  • Apps:

    • starters/themed-smb-site renders serviceCallout from src/cms.renderers.tsx, passed as a prop.
    • examples/blog adds a quote block rendered through the module path, with an E2E test that covers both server render and client navigation.
  • Docs and skills. The blocks-and-rendering guide, the cms-ui-react and cms-core references, the route spec tables, the migration docs and the four migration skills are updated. The upgrade guide gains §22.

  • Changeset: block-renderers-module.md, minor and breaking in pre-mode, for cms-core and cms-ui-react.

Breaking changes

BlockType.component is removed, and passing one throws. To migrate, move the component into a renderers module:

export const renderers = defineRenderers({ blocks: { quote: Quote } })

Then name the module in createRoutes, or pass renderers to BlocksView in your own routes. There's no codemod; upgrading §22 shows before and after.

Assumptions (tasks 8–12 defaults)

  • Module path: relative to the routes directory, like rootFile. The export is named renderers.
  • Binding: module-level, like the existing global lookups, not a React context. Props win.
  • HTML string renderers (renderBlocksToHtml, renderBlockToHtml) stay where they are.
  • No codemod: the change isn't mechanical, because components move to a new file along with their imports.

Divergence from plan

  • Split into two PRs, following Q22.
  • The channel is a real module that the plugin's load hook overrides, not a virtual import. A bare virtual import fails noUncheckedSideEffectImports, and a real file keeps custom rootFiles working.

How verified

CI is down because GitHub Actions is out of billing, so this was run locally. I rebased #25, #28, R2 blocks and R2 fields onto #24's main-based head 2850c54, which is the state after batch 3 merges.

  • pnpm test:ci: passes except the cms-api:test:oxlint failure that main already has.
  • test:dts: clean.
  • test:dialects: passes.
  • test:scripts: 93/93.
  • test:definitions: 26/26.
  • E2E: blog 29/29, base 12/12.

The worker also ran test:pr, the ui-react (105) and core unit tests, and pack-consumer, which fails only on the formsLeadCaptureSkill error that main already has.

The built blog server, run with node .output/server/index.mjs, returned 500 with "Cannot read properties of null (reading 'useRef')". That wasn't a regression: main (3b4a112) and 108e342, from before the refactor, fail the same way. #44 fixes it and merges before this PR, and every chain tip from step 2 on passes the SSR smoke test.

Merge chain (local verification, CI down)

This PR's commits are squashed into one commit on the linear merge chain. That commit holds this PR's own changes, resolved against every PR before it, with the integration rehearsal's fixes for this PR applied.

Two files conflicted, vite.ts and virtual-routes.ts:

In cms-ui-react.md, CmsVitePlugin gains resolveId, and the prose gains #44's SSR sentence.

The chain tip's tree is exactly the integration rehearsal plus #46 (c4e6d7c), and the tip passes the full local suite. I simulated merging every PR in order, with a merge commit or a fast-forward at each step, and every step is clean. A plain squash of the next PR would conflict, because the squash commit isn't an ancestor of the next branch. To squash instead, first rebase the branch's one commit onto the new main; that rebase is always clean.

Open in Web Open in Cursor 

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: TanStack/cms
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 6c6bda9
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Free
  • Run ID: 71ad4f04-df88-46db-8881-843ae1753fed
Commits

Reviewing files that changed from the base of the PR and between 6c6bda9 and b5a0594.

Files selected for processing: 49

  • .changeset/block-renderers-module.md
  • .claude/skills/astro-starlight-to-tanstack-cms/SKILL.md
  • .claude/skills/emdash-to-tanstack-cms/SKILL.md
  • .claude/skills/payload-to-tanstack-cms/SKILL.md
  • .claude/skills/wordpress-to-tanstack-cms/SKILL.md
  • docs/api/cms-core.md
  • docs/api/cms-ui-react.md
  • docs/api/routes-and-endpoints.md
  • docs/architecture/routes-in-a-package.md
  • docs/deployment/upgrading.md
  • docs/migration/from-astro-starlight.md
  • docs/migration/from-payload.md
  • docs/schema/blocks-and-rendering.md
  • docs/schema/building-pages.md
  • examples/blog/e2e/cms.spec.ts
  • examples/blog/src/cms.config.ts
  • examples/blog/src/cms.renderers.tsx
  • examples/blog/vite.config.ts
  • packages/core/src/config.ts
  • packages/core/src/lib/authoring.ts
  • packages/core/src/schema.ts
  • packages/core/tests/plugins.test.ts
  • packages/ui-react/package.json
  • packages/ui-react/src/app-renderers.ts
  • packages/ui-react/src/components/blocks-view.tsx
  • packages/ui-react/src/components/on-page-editor.tsx
  • packages/ui-react/src/components/on-page/page-content.tsx
  • packages/ui-react/src/index.ts
  • packages/ui-react/src/lib/renderers.ts
  • packages/ui-react/src/routes/$.tsx
  • packages/ui-react/src/routes/__root.tsx
  • packages/ui-react/src/routes/agent.tsx
  • packages/ui-react/src/routes/content.tsx
  • packages/ui-react/src/routes/edit.$collection.$id.tsx
  • packages/ui-react/src/routes/index.tsx
  • packages/ui-react/src/routes/p.$id.tsx
  • packages/ui-react/src/routes/post.$id.tsx
  • packages/ui-react/src/routes/preview.$collection.$id.tsx
  • packages/ui-react/src/routes/review.tsx
  • packages/ui-react/src/routes/settings.tsx
  • packages/ui-react/src/site.ts
  • packages/ui-react/src/virtual-routes.ts
  • packages/ui-react/src/vite.ts
  • packages/ui-react/tests/renderers.test.tsx
  • packages/ui-react/tests/virtual-routes.test.ts
  • starters/themed-smb-site/CMS-INTEGRATION.md
  • starters/themed-smb-site/src/cms.renderers.tsx
  • starters/themed-smb-site/src/theme.tsx
  • starters/themed-smb-site/tests/seam.test.ts

TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.

  • Ask an admin to upgrade

Open in CodeRabbit

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@changeset-bot

changeset-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b5a0594

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@tanstack/cms-core Minor
@tanstack/cms-ui-react Minor
@tanstack/cms-api Minor
@tanstack/cms-cli Minor
@tanstack/cms-client Minor
@tanstack/cms-connect-atproto Patch
@tanstack/cms-migrate-wp Patch
@tanstack/cms-skills Patch
@tanstack/cms-media-s3 Minor
@tanstack/search-cms Patch
@tanstack/cms-store-libsql Minor
@tanstack/cms-store-postgres Patch
@tanstack/cms-ui-dom Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…e createRoutes renderers module (R2) (#31)

Chain step 7 of the linear merge chain onto main 3b4a112: this PR's own changes, resolved against the PRs before it in the merge order.

Co-authored-by: jherr <jherr@pobox.com>
@jherr
jherr force-pushed the cursor/renderer-binding-d21e branch from a50f376 to b5a0594 Compare November 6, 2026 15:06
@jherr
jherr merged commit 935c82e into main Nov 6, 2026
1 check passed
@jherr
jherr deleted the cursor/renderer-binding-d21e branch November 8, 2026 01:55
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.

2 participants