refactor(cli-core): replace vite-node with Vite module runner#1224
Draft
stipsan wants to merge 4 commits into
Draft
refactor(cli-core): replace vite-node with Vite module runner#1224stipsan wants to merge 4 commits into
stipsan wants to merge 4 commits into
Conversation
Migrate studioWorkerLoader.worker.ts from ViteNodeServer/ViteNodeRunner to createServerModuleRunner, preserving https:// import handling and source map support via the built-in ModuleRunner API.
Add StudioModuleEvaluator to execute CommonJS modules with vite-node-style interop, and route bare imports through Vite transform to honor ssr.noExternal.
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs main (cdd349b) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 11.13 MB | - |
| Bundled (gzip) | 2.10 MB | - |
| Import time | 882ms | +15ms, +1.7% |
bin:sanity
| Metric | Value | vs main (cdd349b) |
|---|---|---|
| Internal (raw) | 1023 B | - |
| Internal (gzip) | 486 B | - |
| Bundled (raw) | 9.87 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 1.99s | +27ms, +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 — @sanity/cli-core
Compared against main (cdd349bf)
| Metric | Value | vs main (cdd349b) |
|---|---|---|
| Internal (raw) | 96.3 KB | - |
| Internal (gzip) | 22.7 KB | - |
| Bundled (raw) | 21.70 MB | - |
| Bundled (gzip) | 3.45 MB | - |
| Import time | 784ms | +13ms, +1.7% |
🗺️ 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 (cdd349bf)
| Metric | Value | vs main (cdd349b) |
|---|---|---|
| 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.
Contributor
Coverage Delta
No baseline available — showing current coverage for 2 changed files Overall Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1210
Description
Migrates the studio worker loader from
vite-node(ViteNodeServer/ViteNodeRunner) to Vite's built-in Module Runner API (createServerModuleRunner), and removes thevite-nodedependency.The migration preserves the custom behavior requested in the issue:
fetchModulestill fetches remote modules and runs them throughssrTransformStudioModuleEvaluatoradds the CJSmodule/exports/requirecontext that vite-node used to providesourcemapInterceptor(replacesinstallSourcemapsSupport)/@vite/env— loaded viarunner.import('/@vite/env')before the worker scriptFollow-up simplification removed an unused bare-import re-transform branch, cutting 52 lines while keeping the integration tests green.
What to review
packages/@sanity/cli-core/src/loaders/studio/studioWorkerLoader.worker.ts— Module Runner setup and HTTPSfetchModuleoverridepackages/@sanity/cli-core/src/loaders/studio/studioModuleEvaluator.ts— CJS execution evaluatorpackages/@sanity/cli-core/package.jsonandpnpm-workspace.yamlTesting
pnpm check:typespnpm check:lintpnpm check:depspnpm build:clipnpm test packages/@sanity/cli-core packages/@sanity/cli-build/src/actions/build/renderDocumentWorker/__tests__/renderDocumentWorker.test.ts --bail=1(282 tests)pnpm test packages/@sanity/cli/src/commands/schemas/__tests__/extract.test.ts -t "should extract schema" --bail=1(schema extraction integration via studio worker, including worst-case studio)