refactor: Move more build/schema logic to cli-build package#1130
Conversation
|
Claude finished @snocorp's task in 4m 55s —— View job ReviewMostly file moves with sensible package boundaries. A few items worth a look: Issues1. Bundle stats no longer tracks 2. 3. Cursor bot's "leftover env var mocks" comment is already resolved ( Changeset
This better serves anyone (incl. runtime-cli) upgrading across the break. Nits
|
📦 Bundle Stats —
|
| Metric | Value | vs main (cd110e7) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 10.97 MB | - |
| Bundled (gzip) | 2.06 MB | - |
| Import time | 829ms | +9ms, +1.2% |
bin:sanity
| Metric | Value | vs main (cd110e7) |
|---|---|---|
| Internal (raw) | 1023 B | - |
| Internal (gzip) | 486 B | - |
| Bundled (raw) | 9.87 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 1.94s | +217ms, +12.6% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @sanity/cli-core
Compared against main (cd110e7c)
| Metric | Value | vs main (cd110e7) |
|---|---|---|
| Internal (raw) | 96.3 KB | - |
| Internal (gzip) | 22.7 KB | - |
| Bundled (raw) | 21.64 MB | - |
| Bundled (gzip) | 3.43 MB | - |
| Import time | 800ms | +11ms, +1.4% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — create-sanity
Compared against main (cd110e7c)
| Metric | Value | vs main (cd110e7) |
|---|---|---|
| Internal (raw) | 908 B | - |
| Internal (gzip) | 483 B | - |
| Bundled (raw) | 931 B | - |
| Bundled (gzip) | 491 B | - |
| Import time | ❌ ChildProcess denied: node | - |
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
Coverage Delta
Comparing 52 changed files against main @ Overall Coverage
|
Preview this PR with pkg.pr.newRun the Sanity CLInpx https://pkg.pr.new/sanity-io/cli/@sanity/cli@3b8e93c <command>...Or upgrade project dependencies📦
|
macdonst
left a comment
There was a problem hiding this comment.
LGTM Dave, it's mostly file moves anyway so it's not as terrible to review as the 67 changed files might indicate.
|
❌ Bundle Stats — An error occurred while calculating bundle sizes. Error details |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0089805. Configure here.
rexxars
left a comment
There was a problem hiding this comment.
Approving, but see comment - could be the safest approach would be to bump to 0.2.0
| "./_internal/build": { | ||
| "source": "./src/_exports/_internal/build.ts", | ||
| "default": "./dist/_exports/_internal/build.js" | ||
| }, | ||
| "./_internal/extract": { | ||
| "source": "./src/_exports/_internal/extract.ts", | ||
| "default": "./dist/_exports/_internal/extract.js" | ||
| }, |
There was a problem hiding this comment.
I'm perhaps being overly cautious here, but:
Given @sanity/cli-build is a dependency of @sanity/cli, and uses ^ (not pinned versions), there could conceivably be a situation where an old version of the CLI uses the latest version of @sanity/cli-build. In that case, the removal of @sanity/cli-build/_internal would break.
Again, might be a bit overly defensive here - but potentially this should be marked as a breaking to force a new major of the package, or we could use ./internal-extract or some such and leave the old _internal in place
There was a problem hiding this comment.
…but if going with the latter approach, we'd need to make sure that the shape of _internal matches what it was (eg generateWebManifest was part of it previously but seems to be removed from the new)
There was a problem hiding this comment.
Yes, you're correct. Good call. Added a changeset to do a minor bump. I don't think we need backward compat here because it's pre-v1. At least that was my intention. I'll make it v1 once it's finished and stable.
ryanbethel
left a comment
There was a problem hiding this comment.
Just reviewing the most recent changes since the other more in depth reviews previously. This looks good.

Description
This PR moves build and schema logic into the cli-build package in preparation for allowing runtime-cli to execute build logic during deployment.
Testing
Updated tests as needed.
Note
Medium Risk
Breaking change for any consumer of
@sanity/cli-build/_internal; studio build, deploy, and schema flows are touched across many entry points, though behavior is largely a move with dependency injection for env vars.Overview
@sanity/cli-buildno longer exposes a single@sanity/cli-build/_internalentry. Public internals are split into@sanity/cli-build/_internal/build(Vite config, runtime HTML, favicons, vendor deps, build telemetry) and@sanity/cli-build/_internal/extract(schema extraction, validation formatting, pattern matching, extract telemetry). The package picks up the build stack it actually uses (Vite, React, chokidar, etc.) and TSX/JSX build support.@sanity/clinow consumes those subpaths instead of owning duplicate build/schema modules: studio/app build, dev/preview servers, deploy, and schema/manifest/graphql commands import fromcli-build. Env injection for Vite is passed in via agetEnvironmentVariablescallback ongetViteConfig(CLI still supplies app vs studio env helpers). Some telemetry types moved next to the logic incli-build. A few CLI-only deps were dropped from@sanity/cliwhere logic moved.Tests were updated to mock the new import paths; shared
createMockHttpServer/createMockWatcherhelpers moved from CLI test utils into@sanity/cli-test. E2e/tsconfig path mapping uses@sanity/cli-build/*for the split exports. Changeset marks a minor bump for@sanity/cli-builddue to the export break.Reviewed by Cursor Bugbot for commit 3b8e93c. Bugbot is set up for automated code reviews on this repo. Configure here.