Skip to content

feat: upgrade vite to v8, plugin-react to v6, vite-node to v6#698

Draft
binoy14 wants to merge 1 commit intomainfrom
chore/upgrade-vite-8
Draft

feat: upgrade vite to v8, plugin-react to v6, vite-node to v6#698
binoy14 wants to merge 1 commit intomainfrom
chore/upgrade-vite-8

Conversation

@binoy14
Copy link
Copy Markdown
Contributor

@binoy14 binoy14 commented Mar 17, 2026

Summary

  • Upgrade vite from ^7.3.1 to ^8.0.0 (Rolldown-based bundling)
  • Upgrade @vitejs/plugin-react from ^5.2.0 to ^6.0.1 (OXC-based transforms)
  • Upgrade vite-node from ^5.3.0 to ^6.0.0
  • Add @rolldown/plugin-babel for React Compiler support (required by plugin-react v6)

FIXES SDK-1254

Breaking change adaptations

  • Remove originalLength from ChunkModule (removed from rolldown's RenderedModule)
  • Replace treeshake: {preset: 'recommended'} with treeshake: true (rolldown API change)
  • Migrate React Compiler integration from babel option to @rolldown/plugin-babel with reactCompilerPreset (plugin-react v6 dropped built-in Babel support in favor of OXC)

Benchmark: Studio build (worst-case-studio fixture)

Metric Vite 7 (Rollup) Vite 8 (Rolldown) Improvement
Build step ~7.4s ~1.6s ~4.7x faster
Total time ~8.4s ~2.5s ~3.4x faster

Test plan

  • pnpm check:types passes
  • pnpm build:cli passes
  • pnpm check:deps passes
  • pnpm check:lint passes (no new warnings)
  • getViteConfig.test.ts — all 25 tests pass
  • Full test suite — no new failures (3 pre-existing doctor test failures unrelated to this change)
  • Manual test: sanity dev in a studio project
  • Manual test: sanity build in a studio project

🤖 Generated with Claude Code

@claude
Copy link
Copy Markdown

claude Bot commented Mar 17, 2026

Claude finished @binoy14's task in 1m 33s —— View job


Review

  • Read context and analyze changed files
  • Post review findings

1. server.close() can shadow original errorsstudioWorkerLoader.worker.ts:224-230

In the finally block, if runner.executeId(workerScriptPath) throws and server.close() also throws, the original error is replaced by the server.close() error. This could make failures harder to diagnose.

try {
  await runner.executeId(workerScriptPath)
} finally {
  await server.close().catch((err) => {
    debug('Error closing vite server: %s', err)
  })
}

Fix this →


2. reactCompiler config properties beyond compilationMode/target are silently droppedgetViteConfig.ts:151-158

The CliConfig type accepts the full ReactCompilerConfig (which includes fields like panicThreshold, enablePreserveExistingMemoizationGuarantees, etc.). In v5, the entire config object was forwarded to Babel. In v6, only compilationMode and target are passed to reactCompilerPreset. Any other properties a user has in their experimental.reactCompiler config are silently ignored with no warning or type error.

Consider narrowing the reactCompiler config type in CliConfig to only { compilationMode?, target? } so that TypeScript catches unsupported fields at authoring time rather than silently discarding them at runtime.


3. Changeset summary describes internals, not user-facing effect.changeset/pr-698.md

The current summary "upgrade vite to v8, plugin-react to v6, vite-node to v6" lists package names rather than the user-observable benefit. Per repo conventions, it should be one sentence about the user-facing change:

Upgrade to Vite 8 (Rolldown-based) for significantly faster Studio builds.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Mar 17, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​rolldown/​plugin-babel@​0.2.17310010096100
Addednpm/​vite@​8.0.8941008299100
Addednpm/​vite-node@​6.0.010010010093100
Addednpm/​@​vitejs/​plugin-react@​6.0.110010010094100

View full report

@binoy14
Copy link
Copy Markdown
Contributor Author

binoy14 commented Mar 17, 2026

Thanks for the review! The concern about sources being dropped is valid in spirit, but reactCompilerPreset in @vitejs/plugin-react v6 intentionally only accepts compilationMode and target:

declare const reactCompilerPreset: (
  options?: Pick<ReactCompilerBabelPluginOptions, "compilationMode" | "target">
) => RolldownBabelPreset;

Spreading the full config (reactCompilerPreset(reactCompiler)) would cause a type error.

In v6, file filtering (what sources did in v5) is handled differently — via the preset's rolldown.filter property:

const myPreset = reactCompilerPreset()
myPreset.rolldown.filter.id.exclude = ['src/legacy/**', 'src/utils/**']

This is a known narrowing of the plugin-react v6 API. If we need to support the full ReactCompilerConfig surface in the future, we'd need to map unsupported properties (like sources) to the new rolldown.filter equivalent.

@stipsan
Copy link
Copy Markdown
Member

stipsan commented Mar 17, 2026

We certainly don't need to support sources, it's no longer documented https://react.dev/learn/react-compiler/incremental-adoption and is not recommended since tooling like babel, rolldown, etc etc all have different and better ways of filtering by file

},
expect(reactCompilerPreset).toHaveBeenCalledWith({
compilationMode: undefined,
target: '18',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target: '18',
target: '19',

React 19 is the baseline now

@binoy14 binoy14 changed the base branch from main to graphite-base/698 March 18, 2026 04:48
@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch from a0514fb to 2920a1e Compare March 18, 2026 04:48
@binoy14 binoy14 changed the base branch from graphite-base/698 to 03-17-chore_fixes_issue_with_duplicate_cli-core March 18, 2026 04:48
Copy link
Copy Markdown
Contributor Author

binoy14 commented Mar 18, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@binoy14 binoy14 changed the base branch from 03-17-chore_fixes_issue_with_duplicate_cli-core to graphite-base/698 March 18, 2026 05:00
@binoy14 binoy14 force-pushed the graphite-base/698 branch from a23e30e to 1e3f6a4 Compare March 18, 2026 05:00
@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch from 2920a1e to 159c500 Compare March 18, 2026 05:00
@binoy14 binoy14 changed the base branch from graphite-base/698 to main March 18, 2026 05:00
@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch 2 times, most recently from 97c18fa to b41f15c Compare March 30, 2026 14:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 30, 2026

📦 Bundle Stats — @sanity/cli

Compared against main (5115c0d4) · v6.2.1 (npm)

Metric Value vs main (5115c0d) vs v6.2.1
Internal (raw) 2.1 KB - -
Internal (gzip) 799 B - -
Bundled (raw) 11.20 MB - +9.26 MB, +477.8%
Bundled (gzip) 2.10 MB - +1.62 MB, +341.2%
Import time 912ms +21ms, +2.3% +49ms, +5.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 (5115c0d4) · v1.2.1 (npm)

Metric Value vs main (5115c0d) vs v1.2.1
Internal (raw) 89.4 KB - +1.1 KB, +1.3%
Internal (gzip) 20.8 KB - +380 B, +1.8%
Bundled (raw) 21.69 MB - +9.13 MB, +72.7%
Bundled (gzip) 3.44 MB - +1.60 MB, +86.6%
Import time 841ms +23ms, +2.8% +45ms, +5.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.

@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch from b41f15c to e57380b Compare March 30, 2026 15:41
@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch from e57380b to 1ad0c90 Compare April 6, 2026 17:46
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

📦 Bundle Stats — @sanity/cli

Compared against main (88bc2254)

@sanity/cli

Metric Value vs main (88bc225)
Internal (raw) 2.1 KB -
Internal (gzip) 799 B -
Bundled (raw) 11.08 MB -
Bundled (gzip) 2.08 MB -
Import time 898ms +17ms, +2.0%

bin:sanity

Metric Value vs main (88bc225)
Internal (raw) 975 B -
Internal (gzip) 460 B -
Bundled (raw) 9.84 MB -
Bundled (gzip) 1.77 MB -
Import time 2.08s +32ms, +1.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 (88bc2254)

Metric Value vs main (88bc225)
Internal (raw) 93.9 KB +819 B, +0.9%
Internal (gzip) 22.2 KB +285 B, +1.3%
Bundled (raw) 21.62 MB +819 B, +0.0%
Bundled (gzip) 3.42 MB +273 B, +0.0%
Import time 823ms +23ms, +2.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 (88bc2254)

Metric Value vs main (88bc225)
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.

@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch 2 times, most recently from 0207d16 to 00eb23e Compare April 10, 2026 20:56
squiggler-app Bot added a commit that referenced this pull request Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

Coverage Delta

File Statements
packages/@sanity/cli-core/src/loaders/studio/studioWorkerLoader.worker.ts 0.0% (±0%)
packages/@sanity/cli-core/src/util/promisifyWorker.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/build/buildStaticFiles.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%)

Comparing 5 changed files against main @ 88bc22540f51e760f453fc7b5bdaa88e902e09be

Overall Coverage

Metric Coverage
Statements 83.0% (±0%)
Branches 73.0% (+ 0.1%)
Functions 82.9% (±0%)
Lines 83.4% (+ 0.0%)

@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch from 49ac715 to 357a455 Compare April 13, 2026 16:28
@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch from 357a455 to f50f221 Compare April 13, 2026 16:30
@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch from f50f221 to 8824841 Compare April 14, 2026 15:51
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

Preview this PR with pkg.pr.new

Run the Sanity CLI

npx https://pkg.pr.new/sanity-io/cli/@sanity/cli@5f10cab <command>

...Or upgrade project dependencies

📦 @sanity/cli
pnpm install https://pkg.pr.new/@sanity/cli@5f10cab
📦 @sanity/cli-core
pnpm install https://pkg.pr.new/@sanity/cli-core@5f10cab
📦 @sanity/cli-test
pnpm install https://pkg.pr.new/@sanity/cli-test@5f10cab
📦 @sanity/eslint-config-cli
pnpm install https://pkg.pr.new/@sanity/eslint-config-cli@5f10cab

View Commit (5f10cab)

Upgrade vite ecosystem packages for Rolldown-based bundling:
- vite: ^7.3.1 → ^8.0.0
- @vitejs/plugin-react: ^5.2.0 → ^6.0.1
- vite-node: ^5.3.0 → ^6.0.0

Breaking change adaptations:
- Remove `originalLength` from ChunkModule (removed from rolldown's RenderedModule)
- Replace `treeshake: {preset: 'recommended'}` with `treeshake: true` (rolldown API)
- Migrate React Compiler integration from babel option to @rolldown/plugin-babel
  with reactCompilerPreset (plugin-react v6 uses OXC instead of Babel)
- Add @rolldown/plugin-babel dependency for React Compiler support

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@binoy14 binoy14 force-pushed the chore/upgrade-vite-8 branch from 8824841 to 5f10cab Compare April 16, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants