Skip to content

refactor(workbench): thread views/services as one exposes bundle#1424

Merged
gu-stav merged 1 commit into
mainfrom
refactor/workbench-exposes
Jul 3, 2026
Merged

refactor(workbench): thread views/services as one exposes bundle#1424
gu-stav merged 1 commit into
mainfrom
refactor/workbench-exposes

Conversation

@gu-stav

@gu-stav gu-stav commented Jul 2, 2026

Copy link
Copy Markdown
Member

Description

Every hop between the CLI config and the federation build took views and services as parallel parameters, so adding a declaration family (installation config) meant touching each one. Bundle them as a single WorkbenchExposes object — a new family now touches the type and the artifact expanders, not every hop in between.

Also drops the federation plugin's unused raw exposes passthrough, which freed the name.

I've decided to not use interfaces because e.g. installation configs aren't interfaces in the Brett-sense.

Pure threading refactor: no behavior change, no public API change. Base for #1423, which adds the first new family (the media library's installation config).


Note

Low Risk
Internal parameter threading and typing only; tests updated to match; no runtime behavior change described.

Overview
Refactors workbench build/dev plumbing so declared views and services travel as one WorkbenchExposes bundle from CLI config through buildApp/buildStudio, static file bundling, Vite config, and the dev server—instead of separate views and services on every hop.

CLI entry points assemble exposes: { services, views } from unstable_defineApp; workbenchArtifacts and the federation Vite plugin consume that object end-to-end. The federation plugin drops the unused raw exposes record passthrough (the name is now reserved for the declaration bundle). WorkbenchExposes is exported from @sanity/workbench-cli/build for @sanity/cli-build.

No intended behavior or public API change—sets up adding new declaration families (e.g. installation config) by extending the type and artifact expanders only.

Reviewed by Cursor Bugbot for commit d59fddb. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (651dfb45)

@sanity/cli

Metric Value vs main (651dfb4)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 907ms -4ms, -0.4%

bin:sanity

Metric Value vs main (651dfb4)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.33s +1ms, +0.0%

🗺️ 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 (651dfb45)

Metric Value vs main (651dfb4)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 811ms +7ms, +0.9%

🗺️ 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 (651dfb45)

Metric Value vs main (651dfb4)
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.

@gu-stav gu-stav force-pushed the refactor/workbench-exposes branch from 08a446d to 63435cb Compare July 2, 2026 15:30
@gu-stav gu-stav marked this pull request as ready for review July 2, 2026 15:32
@gu-stav gu-stav requested a review from a team as a code owner July 2, 2026 15:32
@gu-stav gu-stav requested a review from joshuaellis July 2, 2026 15:32
@gu-stav gu-stav marked this pull request as draft July 2, 2026 15:35
@gu-stav gu-stav marked this pull request as ready for review July 2, 2026 15:36
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli-build/src/actions/build/buildApp.ts 93.8% (±0%)
packages/@sanity/cli-build/src/actions/build/buildStaticFiles.ts 32.5% (±0%)
packages/@sanity/cli-build/src/actions/build/buildStudio.ts 94.0% (±0%)
packages/@sanity/cli-build/src/actions/build/getViteConfig.ts 97.7% (±0%)
packages/@sanity/cli/src/actions/build/buildApp.ts 77.8% (±0%)
packages/@sanity/cli/src/actions/build/buildStudio.ts 70.0% (±0%)
packages/@sanity/cli/src/actions/dev/servers/getDevServerConfig.ts 100.0% (±0%)
packages/@sanity/workbench-cli/src/actions/build/artifact.ts 16.7% (±0%)
packages/@sanity/workbench-cli/src/actions/build/vite/plugin.ts 5.0% (+ 0.7%)
packages/@sanity/workbench-cli/src/actions/build/vite/workbench-vite-plugins.ts 100.0% (±0%)
packages/@sanity/workbench-cli/src/resolveWorkbenchApp.ts 100.0% (±0%)

Comparing 11 changed files against main @ 651dfb45a58ba0eb1177aebf1d3bb9fc38bf7549

Overall Coverage

Metric Coverage
Statements 73.5% (+ 0.0%)
Branches 63.6% (+ 0.0%)
Functions 67.2% (- 0.0%)
Lines 74.2% (+ 0.0%)

@gu-stav gu-stav force-pushed the refactor/workbench-exposes branch from 63435cb to ad9ff83 Compare July 2, 2026 15:38
Every hop between the CLI config and the federation build (buildApp,
buildStaticFiles, getViteConfig, devServer, workbenchVitePlugins,
federation plugin, workbenchArtifacts) took views and services as
parallel parameters, so adding a declaration family meant touching each
one. Bundle them as a single WorkbenchExposes object — a new family now
touches the type and the artifact expanders, not every hop in between.
Also drops the federation plugin's unused raw exposes passthrough, which
freed the name.
@gu-stav gu-stav force-pushed the refactor/workbench-exposes branch from ad9ff83 to d59fddb Compare July 3, 2026 06:50
@gu-stav gu-stav merged commit bebd59b into main Jul 3, 2026
54 checks passed
@gu-stav gu-stav deleted the refactor/workbench-exposes branch July 3, 2026 08:09
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