Skip to content

feat(ui-react)!: createRoutes(definition, spec) replaces cmsVirtualRoutes(options) - #28

Merged
jherr merged 1 commit into
mainfrom
cursor/create-routes-d21e
Nov 6, 2026
Merged

jherr merged 1 commit into
mainfrom
cursor/create-routes-d21e

Conversation

@jherr

@jherr jherr commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Implements cms-refactor-plan.md § Phase 1d (item 3, "createRoutes(cms, spec) replaces cmsVirtualRoutes(options)").

Merge chain: step 6 of 24. Base: main. Merge it right after #25. The branch is main 3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit 5389063 (tree 64c4428).

What

  • createRoutes(definition, spec?) replaces cmsVirtualRoutes. vite.config.ts imports only ./src/cms.definition.

    • The admin prefix comes from definition.adminBasePath(), and plugin routes come from definition.pluginRoutes(). Neither is repeated in the Vite config.
    • The generated prefixed copies of admin route files are kept.
  • Grammar per surface (public, admin, api):

    • true, or leaving the surface out, mounts the whole surface (see the divergence below).
    • false mounts none.
    • ['review'] mounts only those keys.
    • { agent: false, edit: './x.tsx' } drops or replaces single keys.

    custom replaces children, and rootFile stays top-level.

  • Errors. An unknown key, a key from another surface, the full defineCms config, or any removed option throws. Each removed-option error names its replacement and the codemod.

  • CmsRouteKey is documented public API, with the existing key names kept as the stable names.

  • Build options. routesDirectory and generatedDirectory move to tanstackCms({ … }).

  • Seam for 3c. cmsRouteMounts() is where collection-aware public mounts (3c(ii)) and the shadowing check will go. Neither is built.

  • Codemod. pnpm codemod create-routes, with fixtures.

    • It rewrote the 11 Vite configs, the docs code blocks and the READMEs.
    • The CLI init, pack-consumer, the starter route specs, the skills and the docs prose were updated by hand. The upgrade guide gains §21.
    • PRM becomes createRoutes(definition, { rootFile, public: false, custom }).
    • The double base path is gone: payload-after's /admin and existing-app's /cms-admin now live only in the definition.
  • Collection imports. The collection modules in PRM and picks now import /definition instead of the core root. Vite's config loader loads them in plain Node, which can't load the root from workspace source.

  • Dialect marker. cmsVirtualRoutes is retired, going from 150 non-test uses to 0. The upgrade guide is exempt because it has to name the removed API.

  • Changeset. Minor (breaking) for cms-ui-react and cms-cli, patch for cms-core, with the codemod command.

Breaking changes

cmsVirtualRoutes(options) becomes createRoutes(definition, spec?), and CmsVirtualRoutesOptions becomes CreateRoutesSpec:

Old option New form
include: { public: false } public: false
routes: { post, agent } keys grouped under their surface
children custom
adminBasePath, plugins set in defineCmsDefinition
routesDirectory, generatedDirectory tanstackCms() options

To migrate, run pnpm codemod create-routes <app>.

Assumptions (tasks 8–12 defaults)

  • Release type: breaking changes ship as minor in pre-mode.
  • Route key names: today's names become the stable names.
  • Mount order: CMS routes, then plugin routes, then plugin adminRoutes, then custom.
  • Definition location: the codemod assumes ./src/cms.definition, which holds for every app in the repo.
  • Definition check: createRoutes accepts any object with adminBasePath() and pluginRoutes(), so it doesn't check the defineCmsDefinition brand.

Divergence from plan

  • A surface you leave out is mounted. The plan groups "absent" with false, but its own PRM mapping { public: false, custom } only works if a missing admin and api are mounted. So only false unmounts. As a result, a new route key mounts in apps that don't name its surface; the docs say so.

  • Plugin order. routesDirectory and generatedDirectory reach createRoutes through a global slot that tanstackCms() sets, so tanstackCms() must be called before createRoutes(). With custom directories, the wrong order throws instead of silently using the defaults.

  • The 1b follow-up isn't done, because it isn't a contained change.

    • The definition's collections() returns names only.
    • Nothing carries the definition to client components.
    • The router loads the full config on the client anyway, and other UI internals read it, so switching only the primitives removes no import.

    It would need core to keep the definition and expose a full-schema accessor. After that, requireCollection and two direct reads are the switch points.

  • test:definitions missed the core-root imports in PRM and picks. It loads through tsx, while Vite uses plain Node. A follow-up commit on this PR blocks the @tanstack/cms-core root in definitions.

How verified

  • pnpm test:pr passes, including all 11 app builds, except the cms-api oxlint error that main already has.
  • test:dts, test:dialects, test:definitions (26 of 26), test:scripts (91), kiira (125) and test:docs pass.
  • E2E: blog 28 of 28, base 12 of 12.
  • pack-consumer builds the consumer app with createRoutes(definition), then fails only on the formsLeadCaptureSkill error that main already has.

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. Six files conflicted:

Separately, UI_ROUTES_DIR no longer uses the global URL, because #44's happy-dom test replaces it.

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

Explain Change →

Caution

Review failed

The pull request is closed.

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: ff8f9a6

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-ui-react Minor
@tanstack/cms-cli Minor
@tanstack/cms-core Minor
@tanstack/cms-api 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

@cursor
cursor Bot force-pushed the cursor/definition-split-0c86 branch from b29aea0 to d135174 Compare November 6, 2026 02:57
@cursor
cursor Bot force-pushed the cursor/create-routes-d21e branch from 14f88da to 70d506d Compare November 6, 2026 03:00
cursor Bot pushed a commit that referenced this pull request Nov 6, 2026
…l URL

#44's vite-plugin test imports vite.ts under happy-dom, whose URL class
Node's fileURLToPath rejects; vite.ts now loads virtual-routes.ts (#28).

Co-authored-by: jherr <jherr@pobox.com>
@cursor
cursor Bot force-pushed the cursor/definition-split-0c86 branch from d135174 to ebd385b Compare November 6, 2026 14:50
@cursor
cursor Bot force-pushed the cursor/create-routes-d21e branch from 70d506d to 5389063 Compare November 6, 2026 14:50
@cursor
cursor Bot changed the base branch from cursor/definition-split-0c86 to main November 6, 2026 14:52
…utes(options) (#28)

Chain step 6 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/create-routes-d21e branch from 5389063 to ff8f9a6 Compare November 6, 2026 15:06
@jherr
jherr merged commit 6c6bda9 into main Nov 6, 2026
@jherr
jherr deleted the cursor/create-routes-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