Skip to content

feat(core): add the light @tanstack/cms-core/definition entry and its Node load test - #24

Merged
jherr merged 1 commit into
mainfrom
cursor/definition-entry-0c86
Nov 6, 2026
Merged

jherr merged 1 commit into
mainfrom
cursor/definition-entry-0c86

Conversation

@jherr

@jherr jherr commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Implements cms-refactor-plan.md § Phase 1e(i).

Merge chain: step 4 of 24. Base: main. Merge it right after #23. The branch is main 3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit 1513928 (tree 0f9c1e1).

What

  • A new client- and Node-safe entry, @tanstack/cms-core/definition.
    • defineCmsDefinition({ collections, admin, plugins }) returns a definition with derived, frozen accessors: adminBasePath(), collections(), pluginRoutes() and routeKeys().
    • It also exports isCmsDefinition, CMS_ROUTE_KEYS and the route-key types.
    • The implementation has only type imports, so the entry pulls in nothing at runtime.
  • Authoring needs only this entry. It also exports the pure authoring helpers and the types that collections use, so a cms.definition.ts and its collection modules never import the package root.
    • The helpers are defineCollection, defineBlock, defineFieldType, definePlugin, seoField, assetField, redirectsCollection, isSafeRedirectTarget and isBuiltInFieldType.
    • They moved verbatim into src/lib/authoring.ts, and the root re-exports the same functions. A test asserts they are identical.
  • defineCms(definition, runtime) and createCms(definition, runtime) overloads. The runtime config is CmsConfig minus collections, admin and plugins. Both forms go through the same plugin merging and validation, and a test asserts the resolved configs are equal. defineCms(config) is unchanged.
  • Register accepts the definition. RegisteredCollectionName, RegisteredDoc and RegisteredAdminBasePath infer from it, plugin collections included. A separate tsc project checks this.
  • Route keys live in core. CMS_ROUTE_KEYS is the single source of truth. cms-ui-react keys its route table by it, so a key missing on either side fails tsc. Route output is unchanged.
  • The Node load test, pnpm test:definitions (scripts/verify-definitions.ts), runs in test:pr and test:ci.
    • It loads every cms.definition.ts in a plain Node process behind a module.register() hook. The hook fails on react, react-dom, .tsx/.jsx files, @tanstack/react-start, @tanstack/react-router, the cms-ui-react root, @tanstack/cms-core/server and *.server.* files.
    • It then asserts that the four accessors return values.
    • It only reports here. --strict makes it fail, and 1e(ii) turns that on.
  • Docs and changeset. docs/api/cms-core.md gets a "The CMS definition" section, marked as the recommended shape. The changeset is minor for cms-core and patch for cms-ui-react.

No app, starter or example config is touched; 1e(ii) migrates them.

Breaking changes

None; this is additive.

Divergence from plan

  • collections() returns { name } only. No collection declares a public prefix today, only an opaque path(), so publicPrefix waits for locators in phase 3c.
  • pluginRoutes() entries are { plugin, route }. 1d needs the plugin name for its per-plugin generated route copies.
  • The load test also blocks @tanstack/cms-core/server.
  • blockTypes stays in the runtime config.
  • defineInterfaceCollection stays root-only here. It needs the interface zod schemas and the cron parser. 1e(ii) exports it from /definition as well.
  • A workspace loading pitfall is fixed here. In workspace apps, Vite's config loader leaves @tanstack/* packages to Node, and Node can't resolve extensionless imports in their .ts sources. So every runtime import this entry reaches names its .ts file, and a test guards that.

How verified

  • pnpm test:pr passes except the cms-api oxlint error that main already has. test:dts, test:dialects, test:definitions and test:scripts pass.
  • node scripts/pack-consumer.mjs type-checks the new entry from the packed tarball. It then fails only on the formsLeadCaptureSkill error that main already has.
  • Plain Node loads the built dist/definition.js.

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. No conflicts.

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 

@changeset-bot

changeset-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 494d132

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

@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: 863f6e1
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Free
  • Run ID: 10ec8dd5-92f4-4a64-a639-161392ec6efd
Commits

Reviewing files that changed from the base of the PR and between 863f6e1 and 494d132.

Files selected for processing: 39

  • .changeset/cms-definition-entry.md
  • docs/api/cms-core.md
  • docs/api/cms-ui-react.md
  • knip.json
  • package.json
  • packages/core/package.json
  • packages/core/src/assets.ts
  • packages/core/src/config.ts
  • packages/core/src/definition.ts
  • packages/core/src/index.ts
  • packages/core/src/lib/authoring.ts
  • packages/core/src/lib/definition.ts
  • packages/core/src/lib/seo.ts
  • packages/core/src/schema.ts
  • packages/core/tests/definition.test.ts
  • packages/core/tests/register-definition/register.ts
  • packages/core/tests/register-definition/tsconfig.json
  • packages/core/tsconfig.json
  • packages/core/tsdown.config.ts
  • packages/ui-react/src/virtual-routes.ts
  • scripts/__fixtures__/definitions/clean/cms.definition.ts
  • scripts/__fixtures__/definitions/clean/collections.ts
  • scripts/__fixtures__/definitions/definition-only/cms.definition.ts
  • scripts/__fixtures__/definitions/definition-only/collections.ts
  • scripts/__fixtures__/definitions/no-export/cms.definition.ts
  • scripts/__fixtures__/definitions/react/cms.definition.ts
  • scripts/__fixtures__/definitions/server-file/access.server.ts
  • scripts/__fixtures__/definitions/server-file/cms.definition.ts
  • scripts/__fixtures__/definitions/start/cms.definition.ts
  • scripts/__fixtures__/definitions/tsx-file/cms.definition.ts
  • scripts/__fixtures__/definitions/tsx-file/hero.tsx
  • scripts/__fixtures__/definitions/ui-react-root/cms.definition.ts
  • scripts/lib/definition-guard.mjs
  • scripts/lib/load-definition.mjs
  • scripts/pack-consumer.mjs
  • scripts/verify-definitions.test.ts
  • scripts/verify-definitions.ts
  • tsconfig.docs.json
  • tsconfig.json

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

@jherr
jherr force-pushed the cursor/explicit-roles-6828 branch from 93a9a48 to a3acc49 Compare November 6, 2026 02:39
@cursor
cursor Bot force-pushed the cursor/explicit-roles-6828 branch from a3acc49 to 8553f16 Compare November 6, 2026 02:57
@cursor
cursor Bot force-pushed the cursor/definition-entry-0c86 branch from c76a818 to e126e12 Compare November 6, 2026 02:57
@jherr
jherr changed the base branch from cursor/explicit-roles-6828 to main November 6, 2026 03:16
@jherr
jherr force-pushed the cursor/definition-entry-0c86 branch from e126e12 to 2850c54 Compare November 6, 2026 03:17
@cursor
cursor Bot force-pushed the cursor/definition-entry-0c86 branch from 2850c54 to 1513928 Compare November 6, 2026 14:50
… Node load test (#24)

Chain step 4 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/definition-entry-0c86 branch from 1513928 to 494d132 Compare November 6, 2026 15:06
@jherr
jherr merged commit 02582ea into main Nov 6, 2026
@jherr
jherr deleted the cursor/definition-entry-0c86 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