Skip to content

perf(workbench): preload workbench and warmup dev-server files#1042

Merged
gu-stav merged 2 commits intofeat/workbenchfrom
SDK-1357-cli
May 5, 2026
Merged

perf(workbench): preload workbench and warmup dev-server files#1042
gu-stav merged 2 commits intofeat/workbenchfrom
SDK-1357-cli

Conversation

@gu-stav
Copy link
Copy Markdown
Member

@gu-stav gu-stav commented May 4, 2026

Description

Preload the module federation manifest using a Link HTTP header and HTML tags and warmup more workbench-related files in Vite.

Speeds up loading of workbench - the remoteUrl is known ahead of time. This reduces the waterfall of load manifest -> load entry to load entry.

Companion PR: https://github.com/sanity-io/workbench/pull/182


Note

Low Risk
Low risk: changes are limited to the workbench dev-server startup path and only add optional preloading/warmup behavior when a valid remote URL is configured.

Overview
Speeds up workbench startup by preloading the Module Federation manifest when SANITY_INTERNAL_WORKBENCH_REMOTE_URL is set: writeWorkbenchRuntime now injects preconnect + preload as=fetch hints into the generated index.html, and the Vite dev server adds a middleware that sets a matching Link preload header on / and /index.html.

Improves dev-server responsiveness by expanding Vite server.warmup.clientFiles to include additional workbench modules and by fire-and-forget fetching the remote manifest to warm the remote's transform/module graph. Tests are extended to cover the new warmup list and header/prefetch behavior.

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

@gu-stav gu-stav requested a review from a team as a code owner May 4, 2026 14:09
@gu-stav gu-stav requested review from somerandomdude and removed request for a team May 4, 2026 14:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

📦 Bundle Stats — @sanity/cli

Compared against feat/workbench (236d11ca)

@sanity/cli

Metric Value vs feat/workbench (236d11c)
Internal (raw) 2.1 KB -
Internal (gzip) 799 B -
Bundled (raw) 10.94 MB -
Bundled (gzip) 2.05 MB -
Import time 740ms -2ms, -0.3%

bin:sanity

Metric Value vs feat/workbench (236d11c)
Internal (raw) 975 B -
Internal (gzip) 460 B -
Bundled (raw) 9.84 MB -
Bundled (gzip) 1.77 MB -
Import time 2.08s -18ms, -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 — @sanity/cli-core

Compared against feat/workbench (236d11ca)

Metric Value vs feat/workbench (236d11c)
Internal (raw) 95.5 KB -
Internal (gzip) 22.5 KB -
Bundled (raw) 21.62 MB -
Bundled (gzip) 3.42 MB -
Import time 700ms -5ms, -0.8%

🗺️ 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 feat/workbench (236d11ca)

Metric Value vs feat/workbench (236d11c)
Internal (raw) 976 B -
Internal (gzip) 507 B -
Bundled (raw) 50.7 KB -
Bundled (gzip) 12.6 KB -
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 requested review from joshuaellis and removed request for somerandomdude May 4, 2026 14:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Coverage Delta

File Statements
packages/@sanity/cli-core/src/config/cli/getCliConfig.ts 100.0% (±0%)
packages/@sanity/cli-core/src/config/cli/schemas.ts 100.0% (±0%)
packages/@sanity/cli-core/src/services/cliUserConfig.ts 100.0% (±0%)
packages/@sanity/cli-core/src/util/getSanityConfigDir.ts 66.7% (new)
packages/@sanity/cli/src/actions/build/buildApp.ts 95.1% (±0%)
packages/@sanity/cli/src/actions/build/buildStaticFiles.ts 97.6% (+ 1.0%)
packages/@sanity/cli/src/actions/build/buildStudio.ts 96.5% (±0%)
packages/@sanity/cli/src/actions/build/buildVendorDependencies.ts 67.4% (±0%)
packages/@sanity/cli/src/actions/build/getViteConfig.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/build/writeSanityRuntime.ts 96.0% (+ 0.8%)
packages/@sanity/cli/src/actions/deploy/deployApp.ts 80.5% (±0%)
packages/@sanity/cli/src/actions/dev/devAction.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/dev/devServerRegistry.ts 93.5% (new)
packages/@sanity/cli/src/actions/dev/extractDevServerManifest.ts 20.0% (new)
packages/@sanity/cli/src/actions/dev/getDevServerConfig.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/dev/startAppDevServer.ts 100.0% (+ 13.0%)
packages/@sanity/cli/src/actions/dev/startDevManifestWatcher.ts 90.9% (new)
packages/@sanity/cli/src/actions/dev/startStudioDevServer.ts 100.0% (+ 5.0%)
packages/@sanity/cli/src/actions/dev/startWorkbenchDevServer.ts 98.5% (new)
packages/@sanity/cli/src/actions/dev/writeWorkbenchRuntime.ts 100.0% (new)
packages/@sanity/cli/src/actions/init/bootstrapLocalTemplate.ts 89.7% (±0%)
packages/@sanity/cli/src/actions/init/bootstrapTemplate.ts 0.0% (±0%)
packages/@sanity/cli/src/actions/init/createAppCliConfig.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/init/createCliConfig.ts 100.0% (+ 50.0%)
packages/@sanity/cli/src/actions/init/createStudioConfig.ts 83.3% (±0%)
packages/@sanity/cli/src/actions/init/initAction.ts 97.2% (+ 0.1%)
packages/@sanity/cli/src/actions/init/scaffoldTemplate.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/init/types.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/manifest/extractCoreAppManifest.ts 93.1% (new)
packages/@sanity/cli/src/actions/manifest/extractManifest.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/manifest/types.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/manifest/writeManifestFile.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/dev.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/init.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/manifest/extract.ts 100.0% (±0%)
packages/@sanity/cli/src/constants.ts 100.0% (new)
packages/@sanity/cli/src/prompts/init/federation.ts 100.0% (new)
packages/@sanity/cli/src/server/devServer.ts 94.1% (±0%)
packages/@sanity/cli/src/services/userApplications.ts 92.8% (±0%)

Comparing 39 changed files against main @ 09a30e25f3f6246f967245420f7a91ba764b3690

Overall Coverage

Metric Coverage
Statements 84.5% (+ 0.3%)
Branches 74.5% (+ 0.4%)
Functions 84.3% (+ 0.3%)
Lines 85.0% (+ 0.4%)

@gu-stav gu-stav merged commit 16e7dfe into feat/workbench May 5, 2026
54 checks passed
@gu-stav gu-stav deleted the SDK-1357-cli branch May 5, 2026 09:09
gu-stav added a commit that referenced this pull request May 5, 2026
* perf(workbench): preload workbench and warmup dev-server files

* chore: update auto-generated changeset for PR #1042

---------

Co-authored-by: squiggler-app[bot] <265501495+squiggler-app[bot]@users.noreply.github.com>
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