Skip to content

chore: enable React Compiler in Vitest for all plugins - #1852

Draft
stipsan wants to merge 1 commit into
mainfrom
cursor/react-compiler-vitest-parity-b3de
Draft

chore: enable React Compiler in Vitest for all plugins#1852
stipsan wants to merge 1 commit into
mainfrom
cursor/react-compiler-vitest-parity-b3de

Conversation

@stipsan

@stipsan stipsan commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

Makes React Compiler in Vitest a hard invariant with tsdown.config.ts, so unit tests exercise the same compiled output as published builds (the gap that forced the late Vitest opt-in in #1841 for sanity-plugin-media).

Changes

  1. @sanity/plugin-kit/vitest — new export with reactCompilerPluginForVitest(), a Vite plugin that runs the oxc React Compiler transform over plugin sources in Vitest. The compiler should always run for plugin code, but @vitejs/plugin-react's compiler: true never applies in Vitest (it only compiles browser builds, not Vitest's transform pipeline), so the plugin calls oxc-transform-react directly. It skips non-JSX modules without a react import so oxc DCE cannot drop side-effect imports like @testing-library/jest-dom/vitest in setup files; .tsx/.jsx always compile (automatic-runtime JSX needs no explicit react import).
  2. Backfill — all 47 plugins with React Compiler in tsdown register the shared plugin in vitest.config.ts (a 3-line diff per plugin; skipped @sanity/debug-preview-url-secret-plugin, which has no RC). The package resolves through the root devDependency like vitest / vitest-package-exports — per-plugin workspace:^ devDeps would break the pnpm pack step of plugin builds.
  3. Generatorsvitest.config.ts.hbs emits the same import, so new plugins get parity for free.
  4. CI enforcementscripts/react-compiler-parity fails pnpm test if the tsdown/Vitest wiring drifts, and transforms fixtures through the same server-side Vite pipeline Vitest uses to assert react/compiler-runtime is emitted (hook components, JSX-only modules) and that setup files stay untouched.

Includes a minor changeset for @sanity/plugin-kit (new ./vitest export, published for standalone plugins too). The lockfile diff is intentionally minimal (24 lines) — sanity stays at the 6.11.0-next.38 main currently pins.

Testing

  • pnpm --filter @repo/react-compiler-parity exec vitest run — 5 passed (parity invariant, compile with/without plugin, JSX-only compile, setup-file skip, assist config)
  • pnpm --filter @sanity/plugin-kit exec vitest run — 62 passed (includes updated package-exports snapshot)
  • pnpm --filter @sanity/table exec vitest run — JSX-only icon components compile
  • pnpm --filter @sanity/document-internationalization exec vitest run — 213 passed, jest-dom matchers still register
  • pnpm --filter @sanity/color-input exec vitest run — composes with vanilla-extract
  • pnpm build (52 tasks), pnpm lint, pnpm knip, pnpm format — all pass
Open in Web Open in Cursor 

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview Aug 21, 2026 4:28pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plugins-e2e-test-studio Ignored Ignored Aug 21, 2026 4:28pm

Request Review

@stipsan stipsan added the 🤖 bot label Aug 6, 2026 — with Cursor
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2036db1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sanity/plugin-kit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ E2E Tests

🟢 26 passedview full reportview run

Studio: https://plugins-e2e-test-studio-cyybovm78.sanity.dev

Datasets: pr-1852-chromium-32503033720, pr-1852-firefox-32503033720

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 28.79% 6261 / 21747
🔵 Statements 25.79% 7798 / 30231
🔵 Functions 28.14% 1399 / 4970
🔵 Branches 18.94% 3809 / 20109
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/@sanity/plugin-kit/package.json 100% 100% 100% 100%
packages/@sanity/plugin-kit/src/vitest.ts 83.33% 60% 66.66% 83.33% 39-40
Generated in workflow #9412 for commit 2036db1 by the Vitest Coverage Report Action

@stipsan
stipsan marked this pull request as ready for review August 7, 2026 08:39
@stipsan
stipsan requested a review from a team as a code owner August 7, 2026 08:39
Copilot AI lite review requested due to automatic review settings August 7, 2026 08:39
@stipsan
stipsan requested review from a team as code owners August 7, 2026 08:39
@stipsan
stipsan requested review from pedrobonamin and removed request for a team August 7, 2026 08:39
@stipsan
stipsan enabled auto-merge (squash) August 7, 2026 08:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Enforces React Compiler parity between tsdown.config.ts and vitest.config.ts across the plugins monorepo, so unit tests run against the same compiled output as published builds.

Changes:

  • Update plugin generators (Vitest + package templates) to always wire @rolldown/plugin-babel + reactCompilerPreset, mirroring reactCompiler: true in tsdown.config.ts.
  • Add a new scripts/react-compiler-parity Vitest project that fails CI/tests if compiler parity drifts.
  • Backfill existing plugins’ vitest.config.ts and package.json devDependencies, and document the invariant in agent/skill docs.

Reviewed changes

Copilot reviewed 106 out of 107 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
turbo/generators/templates/vitest.config.ts.hbs Generator now emits RC-aware Vitest config (Babel + preset) and composes with vanilla-extract when present.
turbo/generators/templates/package.json.hbs Generator now includes @rolldown/plugin-babel + @vitejs/plugin-react as devDependencies (catalog).
turbo/generators/templates/README.todo.md.hbs Generator README guidance calls out keeping tsdown/vitest RC wiring in sync.
scripts/react-compiler-parity/package.json New workspace test package for enforcing RC parity.
scripts/react-compiler-parity/vitest.config.ts Vitest config for parity project (node environment).
scripts/react-compiler-parity/react-compiler-parity.test.ts Parity test that scans plugins and asserts Vitest RC wiring when tsdown enables RC.
pnpm-workspace.yaml Adds @rolldown/plugin-babel and @vitejs/plugin-react to the default catalog.
pnpm-lock.yaml Locks new catalog deps and updates workspace dependency graph (also includes a sanity@next resolution bump).
AGENTS.md Documents the “React Compiler Vitest parity” invariant and references enforcement script.
.agents/skills/sanity-plugin-best-practices/references/styling.md Updates vanilla-extract Vitest examples to preserve RC Babel plugin composition.
.agents/skills/plugin-transfer/SKILL.md Transfer guidance now calls out keeping RC parity in Vitest/tsdown.
.agents/skills/plugin-test-coverage/SKILL.md Testing guidance now includes RC parity requirement and enforcement.
.agents/skills/migrate-styled-components-to-vanilla-extract/SKILL.md Migration checklist updated to keep RC Babel plugin while adding vanilla-extract plugin.
plugins/@sanity/assist/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/assist/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/block-insert-picker/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/block-insert-picker/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/code-input/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/code-input/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/color-input/vitest.config.ts Enables RC Babel stack in Vitest and composes with vanilla-extract plugin.
plugins/@sanity/color-input/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/cross-dataset-duplicator/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/cross-dataset-duplicator/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/dashboard/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/dashboard/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/debug-live-sync-tags/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/debug-live-sync-tags/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/document-internationalization/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/document-internationalization/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/embeddings-index-ui/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/embeddings-index-ui/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/form-toolkit/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/form-toolkit/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/google-maps-input/vitest.config.ts Enables RC Babel stack in Vitest and composes with vanilla-extract plugin.
plugins/@sanity/google-maps-input/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/hierarchical-document-list/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/hierarchical-document-list/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/language-filter/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/language-filter/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/orderable-document-list/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/orderable-document-list/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/personalization-plugin/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/personalization-plugin/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/presets/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/presets/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/rich-date-input/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/rich-date-input/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/sanity-plugin-async-list/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/sanity-plugin-async-list/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/sfcc/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/sfcc/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/studio-secrets/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/studio-secrets/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/table/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/table/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/@sanity/vercel-protection-bypass/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/@sanity/vercel-protection-bypass/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-naive-html-serializer/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-naive-html-serializer/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-aprimo/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-aprimo/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-asset-source-unsplash/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-bynder-input/vitest.config.ts Enables RC Babel stack in Vitest and composes with vanilla-extract plugin.
plugins/sanity-plugin-bynder-input/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-cloudinary/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-cloudinary/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-dashboard-widget-document-list/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-dashboard-widget-netlify/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-dashboard-widget-vercel/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-documents-pane/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-documents-pane/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-graph-view/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-graph-view/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-google-translate/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-google-translate/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-hotspot-array/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-hotspot-array/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-iframe-pane/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-iframe-pane/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-internationalized-array/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-internationalized-array/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-latex-input/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-latex-input/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-markdown/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-markdown/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-media/vitest.config.ts Ensures Vitest runs with RC Babel stack for this plugin.
plugins/sanity-plugin-media/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-mux-input/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-mux-input/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-studio-smartling/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-studio-smartling/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-transifex/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-transifex/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-utils/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-utils/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-workflow/vitest.config.ts Enables RC Babel stack in Vitest and composes with vanilla-extract plugin.
plugins/sanity-plugin-workflow/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-workspace-home/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-workspace-home/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-plugin-shopify-assets/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-plugin-shopify-assets/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).
plugins/sanity-translations-tab/vitest.config.ts Enables RC Babel stack in Vitest for this plugin.
plugins/sanity-translations-tab/package.json Adds @rolldown/plugin-babel + @vitejs/plugin-react devDependencies (catalog).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/react-compiler-parity/react-compiler-parity.test.ts
Comment thread scripts/react-compiler-parity/react-compiler-parity.test.ts
pedrobonamin
pedrobonamin previously approved these changes Aug 10, 2026

@pedrobonamin pedrobonamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 106 out of 107 changed files in this pull request and generated no new comments.

Suppressed comments (2)

scripts/react-compiler-parity/react-compiler-parity.test.ts:66

  • The detection logic is very permissive and can produce false passes/fails (eg, reactCompiler: mentioned in a comment, or reactCompilerPreset imported but not actually wired). Since this test is enforcing a hard invariant, it should verify the concrete patterns you expect: reactCompiler: true / reactCompiler: {…} in tsdown, and a pluginBabel({presets: [reactCompilerPreset()]}) call in vitest config.
    scripts/react-compiler-parity/react-compiler-parity.test.ts:18
  • This parity test may be flaky on slower CI machines: it recursively walks the entire plugins/ tree and reads many files, but it uses the default Vitest timeout. Consider adding an explicit timeout (matching the repo’s 30_000ms convention) to avoid intermittent failures.

Copilot AI review requested due to automatic review settings August 20, 2026 10:42
Comment thread plugins/@sanity/assist/vitest.config.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 106 out of 107 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 20, 2026 10:47

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Compiler skipped in Vitest tests
    • Confirmed the preset's client-only applyToEnvironmentHook made @rolldown/plugin-babel drop it in Vitest's SSR environment; fixed by overriding the hook to always apply in every plugin vitest.config.ts and the generator template, and strengthened the parity check to require the override.

Create PR

Or push these changes by commenting:

@cursor push 1761f57462
Preview (1761f57462)
diff --git a/.agents/skills/migrate-styled-components-to-vanilla-extract/SKILL.md b/.agents/skills/migrate-styled-components-to-vanilla-extract/SKILL.md
--- a/.agents/skills/migrate-styled-components-to-vanilla-extract/SKILL.md
+++ b/.agents/skills/migrate-styled-components-to-vanilla-extract/SKILL.md
@@ -213,10 +213,16 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
   // Keep React Compiler (matches `reactCompiler: true` in tsdown.config.ts) and
   // compose vanilla-extract — do not replace the babel plugin.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
+  plugins: [pluginBabel({presets: [reactCompiler]}), vanillaExtractPlugin()],
   // ...existing test config
 })

@@ -286,7 +292,7 @@

  • tsdown.config.ts: styledComponents removed, vanillaExtract: true added
  • package.json: vanilla-extract devDeps added; styled-components peer removed; sanity /
    @sanity/ui peer variants verified aligned in pnpm-lock.yaml
    -- [ ] vitest.config.ts registers vanillaExtractPlugin() alongside the existing React Compiler babel plugin (pluginBabel({presets: [reactCompilerPreset()]})) — do not drop compiler parity
    +- [ ] vitest.config.ts registers vanillaExtractPlugin() alongside the existing React Compiler babel plugin (pluginBabel with the applyToEnvironmentHook-overridden reactCompilerPreset()) — do not drop compiler parity
  • dist/bundle.css emitted with all rules; package-exports snapshot updated
  • pnpm format / pnpm lint / pnpm knip / pnpm build / pnpm test run all pass
  • Visual fidelity verified against the pre-migration rendering

diff --git a/.agents/skills/plugin-test-coverage/SKILL.md b/.agents/skills/plugin-test-coverage/SKILL.md
--- a/.agents/skills/plugin-test-coverage/SKILL.md
+++ b/.agents/skills/plugin-test-coverage/SKILL.md
@@ -41,7 +41,7 @@

  • Context/provider tests: mock useClient / useWorkspace / pane hooks; use Suspense + act for async React.use language resolution; call any module-level clear() between tests.
  • Timeouts: test('name', {timeout: 30_000}, async () => { … }) — options object as second arg.
  • Keep the package-exports snapshot test; update with pnpm test -u only when exports intentionally change.
    -- React Compiler is on in both build and Vitest — do not add unnecessary useMemo / useCallback. If tsdown.config.ts has reactCompiler: true, vitest.config.ts must register pluginBabel({presets: [reactCompilerPreset()]}) (same stack as @sanity/tsdown-config). Generators wire both; compose with other Vitest plugins rather than replacing them. Enforced by scripts/react-compiler-parity.
    +- React Compiler is on in both build and Vitest — do not add unnecessary useMemo / useCallback. If tsdown.config.ts has reactCompiler: true, vitest.config.ts must register pluginBabel with reactCompilerPreset() and override the preset's applyToEnvironmentHook to always apply (Vitest transforms run in the SSR environment, which the default client-only hook excludes) — same stack as @sanity/tsdown-config. Generators wire both; compose with other Vitest plugins rather than replacing them. Enforced by scripts/react-compiler-parity.

Run a single package:

diff --git a/.agents/skills/sanity-plugin-best-practices/references/styling.md b/.agents/skills/sanity-plugin-best-practices/references/styling.md
--- a/.agents/skills/sanity-plugin-best-practices/references/styling.md
+++ b/.agents/skills/sanity-plugin-best-practices/references/styling.md
@@ -209,9 +209,14 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms run in the SSR environment; override the preset's
+// client-only applyToEnvironmentHook so the compiler is not skipped.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Keep React Compiler (matches tsdown reactCompiler: true) and compose VE.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
  • plugins: [pluginBabel({presets: [reactCompiler]}), vanillaExtractPlugin()],
    // ...
    })
@@ -242,8 +247,11 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
+  plugins: [pluginBabel({presets: [reactCompiler]}), vanillaExtractPlugin()],
  test: {
    setupFiles: ['@vanilla-extract/css/disableRuntimeStyles'],
    // ...

diff --git a/AGENTS.md b/AGENTS.md
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -295,8 +295,14 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [reactCompiler]})],
  // ...
})

diff --git a/plugins/@sanity/assist/vitest.config.ts b/plugins/@sanity/assist/vitest.config.ts
--- a/plugins/@sanity/assist/vitest.config.ts
+++ b/plugins/@sanity/assist/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/block-insert-picker/vitest.config.ts b/plugins/@sanity/block-insert-picker/vitest.config.ts
--- a/plugins/@sanity/block-insert-picker/vitest.config.ts
+++ b/plugins/@sanity/block-insert-picker/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    environment: 'jsdom',
    server: {

diff --git a/plugins/@sanity/code-input/vitest.config.ts b/plugins/@sanity/code-input/vitest.config.ts
--- a/plugins/@sanity/code-input/vitest.config.ts
+++ b/plugins/@sanity/code-input/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/color-input/vitest.config.ts b/plugins/@sanity/color-input/vitest.config.ts
--- a/plugins/@sanity/color-input/vitest.config.ts
+++ b/plugins/@sanity/color-input/vitest.config.ts
@@ -3,9 +3,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
  • plugins: [pluginBabel({presets: [reactCompiler]}), vanillaExtractPlugin()],
    test: {
    setupFiles: ['@vanilla-extract/css/disableRuntimeStyles'],
    server: {

diff --git a/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts b/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
--- a/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
+++ b/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/dashboard/vitest.config.ts b/plugins/@sanity/dashboard/vitest.config.ts
--- a/plugins/@sanity/dashboard/vitest.config.ts
+++ b/plugins/@sanity/dashboard/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/debug-live-sync-tags/vitest.config.ts b/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
--- a/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
+++ b/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/document-internationalization/vitest.config.ts b/plugins/@sanity/document-internationalization/vitest.config.ts
--- a/plugins/@sanity/document-internationalization/vitest.config.ts
+++ b/plugins/@sanity/document-internationalization/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    environment: 'jsdom',
    setupFiles: ['./src/test/setup.ts'],

diff --git a/plugins/@sanity/embeddings-index-ui/vitest.config.ts b/plugins/@sanity/embeddings-index-ui/vitest.config.ts
--- a/plugins/@sanity/embeddings-index-ui/vitest.config.ts
+++ b/plugins/@sanity/embeddings-index-ui/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/form-toolkit/vitest.config.ts b/plugins/@sanity/form-toolkit/vitest.config.ts
--- a/plugins/@sanity/form-toolkit/vitest.config.ts
+++ b/plugins/@sanity/form-toolkit/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    // Component tests opt into jsdom per-file via // @vitest-environment jsdom.
    // The default stays node so the package-exports test keeps resolving sanity

diff --git a/plugins/@sanity/google-maps-input/vitest.config.ts b/plugins/@sanity/google-maps-input/vitest.config.ts
--- a/plugins/@sanity/google-maps-input/vitest.config.ts
+++ b/plugins/@sanity/google-maps-input/vitest.config.ts
@@ -3,9 +3,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
  • plugins: [pluginBabel({presets: [reactCompiler]}), vanillaExtractPlugin()],
    test: {
    setupFiles: ['@vanilla-extract/css/disableRuntimeStyles'],
    server: {

diff --git a/plugins/@sanity/hierarchical-document-list/vitest.config.ts b/plugins/@sanity/hierarchical-document-list/vitest.config.ts
--- a/plugins/@sanity/hierarchical-document-list/vitest.config.ts
+++ b/plugins/@sanity/hierarchical-document-list/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/language-filter/vitest.config.ts b/plugins/@sanity/language-filter/vitest.config.ts
--- a/plugins/@sanity/language-filter/vitest.config.ts
+++ b/plugins/@sanity/language-filter/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    environment: 'jsdom',
    setupFiles: ['./src/test/setup.ts'],

diff --git a/plugins/@sanity/orderable-document-list/vitest.config.ts b/plugins/@sanity/orderable-document-list/vitest.config.ts
--- a/plugins/@sanity/orderable-document-list/vitest.config.ts
+++ b/plugins/@sanity/orderable-document-list/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/personalization-plugin/vitest.config.ts b/plugins/@sanity/personalization-plugin/vitest.config.ts
--- a/plugins/@sanity/personalization-plugin/vitest.config.ts
+++ b/plugins/@sanity/personalization-plugin/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/presets/vitest.config.ts b/plugins/@sanity/presets/vitest.config.ts
--- a/plugins/@sanity/presets/vitest.config.ts
+++ b/plugins/@sanity/presets/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    environment: 'jsdom',
    setupFiles: ['./src/test/setup.ts'],

diff --git a/plugins/@sanity/rich-date-input/vitest.config.ts b/plugins/@sanity/rich-date-input/vitest.config.ts
--- a/plugins/@sanity/rich-date-input/vitest.config.ts
+++ b/plugins/@sanity/rich-date-input/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts b/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
--- a/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
+++ b/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/sfcc/vitest.config.ts b/plugins/@sanity/sfcc/vitest.config.ts
--- a/plugins/@sanity/sfcc/vitest.config.ts
+++ b/plugins/@sanity/sfcc/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/studio-secrets/vitest.config.ts b/plugins/@sanity/studio-secrets/vitest.config.ts
--- a/plugins/@sanity/studio-secrets/vitest.config.ts
+++ b/plugins/@sanity/studio-secrets/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    environment: 'jsdom',
    setupFiles: ['./src/test/setup.ts'],

diff --git a/plugins/@sanity/table/vitest.config.ts b/plugins/@sanity/table/vitest.config.ts
--- a/plugins/@sanity/table/vitest.config.ts
+++ b/plugins/@sanity/table/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/@sanity/vercel-protection-bypass/vitest.config.ts b/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
--- a/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
+++ b/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-naive-html-serializer/vitest.config.ts b/plugins/sanity-naive-html-serializer/vitest.config.ts
--- a/plugins/sanity-naive-html-serializer/vitest.config.ts
+++ b/plugins/sanity-naive-html-serializer/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    environment: 'jsdom',
    setupFiles: ['./test/global.setup.ts'],

diff --git a/plugins/sanity-plugin-aprimo/vitest.config.ts b/plugins/sanity-plugin-aprimo/vitest.config.ts
--- a/plugins/sanity-plugin-aprimo/vitest.config.ts
+++ b/plugins/sanity-plugin-aprimo/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts b/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
--- a/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
+++ b/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-bynder-input/vitest.config.ts b/plugins/sanity-plugin-bynder-input/vitest.config.ts
--- a/plugins/sanity-plugin-bynder-input/vitest.config.ts
+++ b/plugins/sanity-plugin-bynder-input/vitest.config.ts
@@ -3,9 +3,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
  • plugins: [pluginBabel({presets: [reactCompiler]}), vanillaExtractPlugin()],
    test: {
    setupFiles: ['@vanilla-extract/css/disableRuntimeStyles'],
    server: {

diff --git a/plugins/sanity-plugin-cloudinary/vitest.config.ts b/plugins/sanity-plugin-cloudinary/vitest.config.ts
--- a/plugins/sanity-plugin-cloudinary/vitest.config.ts
+++ b/plugins/sanity-plugin-cloudinary/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-documents-pane/vitest.config.ts b/plugins/sanity-plugin-documents-pane/vitest.config.ts
--- a/plugins/sanity-plugin-documents-pane/vitest.config.ts
+++ b/plugins/sanity-plugin-documents-pane/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-google-translate/vitest.config.ts b/plugins/sanity-plugin-google-translate/vitest.config.ts
--- a/plugins/sanity-plugin-google-translate/vitest.config.ts
+++ b/plugins/sanity-plugin-google-translate/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-graph-view/vitest.config.ts b/plugins/sanity-plugin-graph-view/vitest.config.ts
--- a/plugins/sanity-plugin-graph-view/vitest.config.ts
+++ b/plugins/sanity-plugin-graph-view/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
+const reactCompiler = reactCompilerPreset()
+reactCompiler.rolldown.applyToEnvironmentHook = () => true
+
export default defineConfig({
// Match reactCompiler: true in tsdown.config.ts so tests exercise compiled output.

  • plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
  • plugins: [pluginBabel({presets: [reactCompiler]})],
    test: {
    server: {
    deps: {

diff --git a/plugins/sanity-plugin-hotspot-array/vitest.config.ts b/plugins/sanity-plugin-hotspot-array/vitest.config.ts
--- a/plugins/sanity-plugin-hotspot-array/vitest.config.ts
+++ b/plugins/sanity-plugin-hotspot-array/vitest.config.ts
@@ -2,9 +2,15 @@
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

+// Vitest transforms modules through the SSR environment ('server' consumer), which
+// reactCompilerPreset()'s default applyToEnvironmentHook excludes. Apply it
+// unconditionally so tests exercise compiled output, like published tsdown builds.
... diff truncated: showing 800 of 1144 lines


</details>


<sub>You can send follow-ups to the cloud agent <a href="https://cursor.com/agents/bc-b85de904-482c-4f87-b891-d955dfa76905">here</a>.</sub>

</details>

Comment thread AGENTS.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 106 out of 107 changed files in this pull request and generated no new comments.

@cursor

cursor Bot commented Aug 20, 2026

Copy link
Copy Markdown

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Compiler preset skipped in Vitest
    • Confirmed that Vitest's ssr transform environment dropped reactCompilerPreset via its client-only applyToEnvironmentHook, so node-environment tests ran uncompiled src; fixed by lifting the gate (applyToEnvironmentHook = () => true) in all 47 plugin vitest configs and the generator template, and hardened the parity test to enforce the gate lift.

Create PR

Or push these changes by commenting:

@cursor push 2983be7d99
Preview (2983be7d99)
diff --git a/AGENTS.md b/AGENTS.md
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -295,8 +295,14 @@
 import pluginBabel from '@rolldown/plugin-babel'
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 
+// reactCompilerPreset only applies to Vite environments with `consumer === 'client'`, but
+// Vitest transforms node-environment tests through the `ssr` environment — lift the gate
+// so those tests do not silently run uncompiled `src`.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {jsx: {runtime: 'automatic'}},
   // ...
 })

diff --git a/plugins/@sanity/assist/vitest.config.ts b/plugins/@sanity/assist/vitest.config.ts
--- a/plugins/@sanity/assist/vitest.config.ts
+++ b/plugins/@sanity/assist/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/block-insert-picker/vitest.config.ts b/plugins/@sanity/block-insert-picker/vitest.config.ts
--- a/plugins/@sanity/block-insert-picker/vitest.config.ts
+++ b/plugins/@sanity/block-insert-picker/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/code-input/vitest.config.ts b/plugins/@sanity/code-input/vitest.config.ts
--- a/plugins/@sanity/code-input/vitest.config.ts
+++ b/plugins/@sanity/code-input/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/color-input/vitest.config.ts b/plugins/@sanity/color-input/vitest.config.ts
--- a/plugins/@sanity/color-input/vitest.config.ts
+++ b/plugins/@sanity/color-input/vitest.config.ts
@@ -3,9 +3,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
+  plugins: [pluginBabel({presets: [compilerPreset]}), vanillaExtractPlugin()],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts b/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
--- a/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
+++ b/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/dashboard/vitest.config.ts b/plugins/@sanity/dashboard/vitest.config.ts
--- a/plugins/@sanity/dashboard/vitest.config.ts
+++ b/plugins/@sanity/dashboard/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/debug-live-sync-tags/vitest.config.ts b/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
--- a/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
+++ b/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/document-internationalization/vitest.config.ts b/plugins/@sanity/document-internationalization/vitest.config.ts
--- a/plugins/@sanity/document-internationalization/vitest.config.ts
+++ b/plugins/@sanity/document-internationalization/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/embeddings-index-ui/vitest.config.ts b/plugins/@sanity/embeddings-index-ui/vitest.config.ts
--- a/plugins/@sanity/embeddings-index-ui/vitest.config.ts
+++ b/plugins/@sanity/embeddings-index-ui/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/form-toolkit/vitest.config.ts b/plugins/@sanity/form-toolkit/vitest.config.ts
--- a/plugins/@sanity/form-toolkit/vitest.config.ts
+++ b/plugins/@sanity/form-toolkit/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/google-maps-input/vitest.config.ts b/plugins/@sanity/google-maps-input/vitest.config.ts
--- a/plugins/@sanity/google-maps-input/vitest.config.ts
+++ b/plugins/@sanity/google-maps-input/vitest.config.ts
@@ -3,9 +3,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
+  plugins: [pluginBabel({presets: [compilerPreset]}), vanillaExtractPlugin()],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/hierarchical-document-list/vitest.config.ts b/plugins/@sanity/hierarchical-document-list/vitest.config.ts
--- a/plugins/@sanity/hierarchical-document-list/vitest.config.ts
+++ b/plugins/@sanity/hierarchical-document-list/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/language-filter/vitest.config.ts b/plugins/@sanity/language-filter/vitest.config.ts
--- a/plugins/@sanity/language-filter/vitest.config.ts
+++ b/plugins/@sanity/language-filter/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/orderable-document-list/vitest.config.ts b/plugins/@sanity/orderable-document-list/vitest.config.ts
--- a/plugins/@sanity/orderable-document-list/vitest.config.ts
+++ b/plugins/@sanity/orderable-document-list/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/personalization-plugin/vitest.config.ts b/plugins/@sanity/personalization-plugin/vitest.config.ts
--- a/plugins/@sanity/personalization-plugin/vitest.config.ts
+++ b/plugins/@sanity/personalization-plugin/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/presets/vitest.config.ts b/plugins/@sanity/presets/vitest.config.ts
--- a/plugins/@sanity/presets/vitest.config.ts
+++ b/plugins/@sanity/presets/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/rich-date-input/vitest.config.ts b/plugins/@sanity/rich-date-input/vitest.config.ts
--- a/plugins/@sanity/rich-date-input/vitest.config.ts
+++ b/plugins/@sanity/rich-date-input/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts b/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
--- a/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
+++ b/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/sfcc/vitest.config.ts b/plugins/@sanity/sfcc/vitest.config.ts
--- a/plugins/@sanity/sfcc/vitest.config.ts
+++ b/plugins/@sanity/sfcc/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/studio-secrets/vitest.config.ts b/plugins/@sanity/studio-secrets/vitest.config.ts
--- a/plugins/@sanity/studio-secrets/vitest.config.ts
+++ b/plugins/@sanity/studio-secrets/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/table/vitest.config.ts b/plugins/@sanity/table/vitest.config.ts
--- a/plugins/@sanity/table/vitest.config.ts
+++ b/plugins/@sanity/table/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/@sanity/vercel-protection-bypass/vitest.config.ts b/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
--- a/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
+++ b/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-naive-html-serializer/vitest.config.ts b/plugins/sanity-naive-html-serializer/vitest.config.ts
--- a/plugins/sanity-naive-html-serializer/vitest.config.ts
+++ b/plugins/sanity-naive-html-serializer/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-aprimo/vitest.config.ts b/plugins/sanity-plugin-aprimo/vitest.config.ts
--- a/plugins/sanity-plugin-aprimo/vitest.config.ts
+++ b/plugins/sanity-plugin-aprimo/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts b/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
--- a/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
+++ b/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-bynder-input/vitest.config.ts b/plugins/sanity-plugin-bynder-input/vitest.config.ts
--- a/plugins/sanity-plugin-bynder-input/vitest.config.ts
+++ b/plugins/sanity-plugin-bynder-input/vitest.config.ts
@@ -3,9 +3,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
+  plugins: [pluginBabel({presets: [compilerPreset]}), vanillaExtractPlugin()],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-cloudinary/vitest.config.ts b/plugins/sanity-plugin-cloudinary/vitest.config.ts
--- a/plugins/sanity-plugin-cloudinary/vitest.config.ts
+++ b/plugins/sanity-plugin-cloudinary/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-documents-pane/vitest.config.ts b/plugins/sanity-plugin-documents-pane/vitest.config.ts
--- a/plugins/sanity-plugin-documents-pane/vitest.config.ts
+++ b/plugins/sanity-plugin-documents-pane/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-google-translate/vitest.config.ts b/plugins/sanity-plugin-google-translate/vitest.config.ts
--- a/plugins/sanity-plugin-google-translate/vitest.config.ts
+++ b/plugins/sanity-plugin-google-translate/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-graph-view/vitest.config.ts b/plugins/sanity-plugin-graph-view/vitest.config.ts
--- a/plugins/sanity-plugin-graph-view/vitest.config.ts
+++ b/plugins/sanity-plugin-graph-view/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-hotspot-array/vitest.config.ts b/plugins/sanity-plugin-hotspot-array/vitest.config.ts
--- a/plugins/sanity-plugin-hotspot-array/vitest.config.ts
+++ b/plugins/sanity-plugin-hotspot-array/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-iframe-pane/vitest.config.ts b/plugins/sanity-plugin-iframe-pane/vitest.config.ts
--- a/plugins/sanity-plugin-iframe-pane/vitest.config.ts
+++ b/plugins/sanity-plugin-iframe-pane/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-internationalized-array/vitest.config.ts b/plugins/sanity-plugin-internationalized-array/vitest.config.ts
--- a/plugins/sanity-plugin-internationalized-array/vitest.config.ts
+++ b/plugins/sanity-plugin-internationalized-array/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-latex-input/vitest.config.ts b/plugins/sanity-plugin-latex-input/vitest.config.ts
--- a/plugins/sanity-plugin-latex-input/vitest.config.ts
+++ b/plugins/sanity-plugin-latex-input/vitest.config.ts
@@ -2,9 +2,14 @@
 import {reactCompilerPreset} from '@vitejs/plugin-react'
 import {defineConfig} from 'vitest/config'
 
+// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
+// Vitest transforms node-environment tests through the `ssr` Vite environment, where the
+// preset's client-only default would silently drop the compiler — apply it everywhere.
+const compilerPreset = reactCompilerPreset()
+compilerPreset.rolldown.applyToEnvironmentHook = () => true
+
 export default defineConfig({
-  // Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
-  plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
+  plugins: [pluginBabel({presets: [compilerPreset]})],
   oxc: {
     jsx: {runtime: 'automatic'},
   },

diff --git a/plugins/sanity-plugin-markdown/vitest.config.ts b/plugins/sanity-plugin-markdown/vitest.config.ts
--- a/plugins/sanity-plugin-markdown/vitest.config.ts
+++ b/plugins/sanity-plugin-markdown/vitest.config.ts
... diff truncated: showing 800 of 1063 lines

You can send follow-ups to the cloud agent here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 107 out of 108 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

scripts/react-compiler-parity/react-compiler-parity.test.ts:30

  • This test walks the entire plugins/ tree and reads many files, but it uses Vitest's default timeout (typically 5s). That can be flaky on slower CI machines; the other tests in this file already set {timeout: 30_000}.

Comment thread scripts/react-compiler-parity/react-compiler-parity.test.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 107 out of 108 changed files in this pull request and generated no new comments.

Suppressed comments (2)

scripts/react-compiler-parity/react-compiler-parity.test.ts:90

  • import(path.join(...)) uses an absolute path string as a module specifier; this is not reliably cross-platform (notably on Windows). Convert the path to a file:// URL via pathToFileURL(...).href before importing.
    scripts/react-compiler-parity/react-compiler-parity.test.ts:4
  • Dynamic import later in this test should use a file URL. Importing an absolute filesystem path string works on POSIX, but is unreliable on Windows (backslashes / drive letters) and can break import() resolution. Add pathToFileURL so the specifier is portable.

This issue also appears on line 87 of the same file.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Skip misses JSX-only React modules
    • Changed the skip in every copy of reactCompilerPluginForVitest (all plugin vitest configs, the generator template, the parity test, and docs) so .tsx/.jsx files always run oxc-transform-react while non-JSX modules without a react import still skip, and added a JSX-only parity test fixture that fails against the old regex.

Create PR

Or push these changes by commenting:

@cursor push 5e98bbcc30
Preview (5e98bbcc30)
diff --git a/.agents/skills/sanity-plugin-best-practices/references/styling.md b/.agents/skills/sanity-plugin-best-practices/references/styling.md
--- a/.agents/skills/sanity-plugin-best-practices/references/styling.md
+++ b/.agents/skills/sanity-plugin-best-practices/references/styling.md
@@ -216,9 +216,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {
@@ -278,9 +279,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/AGENTS.md b/AGENTS.md
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -307,9 +307,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/assist/vitest.config.ts b/plugins/@sanity/assist/vitest.config.ts
--- a/plugins/@sanity/assist/vitest.config.ts
+++ b/plugins/@sanity/assist/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/block-insert-picker/vitest.config.ts b/plugins/@sanity/block-insert-picker/vitest.config.ts
--- a/plugins/@sanity/block-insert-picker/vitest.config.ts
+++ b/plugins/@sanity/block-insert-picker/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/code-input/vitest.config.ts b/plugins/@sanity/code-input/vitest.config.ts
--- a/plugins/@sanity/code-input/vitest.config.ts
+++ b/plugins/@sanity/code-input/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/color-input/vitest.config.ts b/plugins/@sanity/color-input/vitest.config.ts
--- a/plugins/@sanity/color-input/vitest.config.ts
+++ b/plugins/@sanity/color-input/vitest.config.ts
@@ -11,9 +11,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts b/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
--- a/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
+++ b/plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/dashboard/vitest.config.ts b/plugins/@sanity/dashboard/vitest.config.ts
--- a/plugins/@sanity/dashboard/vitest.config.ts
+++ b/plugins/@sanity/dashboard/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/debug-live-sync-tags/vitest.config.ts b/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
--- a/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
+++ b/plugins/@sanity/debug-live-sync-tags/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/document-internationalization/vitest.config.ts b/plugins/@sanity/document-internationalization/vitest.config.ts
--- a/plugins/@sanity/document-internationalization/vitest.config.ts
+++ b/plugins/@sanity/document-internationalization/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/embeddings-index-ui/vitest.config.ts b/plugins/@sanity/embeddings-index-ui/vitest.config.ts
--- a/plugins/@sanity/embeddings-index-ui/vitest.config.ts
+++ b/plugins/@sanity/embeddings-index-ui/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/form-toolkit/vitest.config.ts b/plugins/@sanity/form-toolkit/vitest.config.ts
--- a/plugins/@sanity/form-toolkit/vitest.config.ts
+++ b/plugins/@sanity/form-toolkit/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/google-maps-input/vitest.config.ts b/plugins/@sanity/google-maps-input/vitest.config.ts
--- a/plugins/@sanity/google-maps-input/vitest.config.ts
+++ b/plugins/@sanity/google-maps-input/vitest.config.ts
@@ -11,9 +11,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/hierarchical-document-list/vitest.config.ts b/plugins/@sanity/hierarchical-document-list/vitest.config.ts
--- a/plugins/@sanity/hierarchical-document-list/vitest.config.ts
+++ b/plugins/@sanity/hierarchical-document-list/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/language-filter/vitest.config.ts b/plugins/@sanity/language-filter/vitest.config.ts
--- a/plugins/@sanity/language-filter/vitest.config.ts
+++ b/plugins/@sanity/language-filter/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/orderable-document-list/vitest.config.ts b/plugins/@sanity/orderable-document-list/vitest.config.ts
--- a/plugins/@sanity/orderable-document-list/vitest.config.ts
+++ b/plugins/@sanity/orderable-document-list/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/personalization-plugin/vitest.config.ts b/plugins/@sanity/personalization-plugin/vitest.config.ts
--- a/plugins/@sanity/personalization-plugin/vitest.config.ts
+++ b/plugins/@sanity/personalization-plugin/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/presets/vitest.config.ts b/plugins/@sanity/presets/vitest.config.ts
--- a/plugins/@sanity/presets/vitest.config.ts
+++ b/plugins/@sanity/presets/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/rich-date-input/vitest.config.ts b/plugins/@sanity/rich-date-input/vitest.config.ts
--- a/plugins/@sanity/rich-date-input/vitest.config.ts
+++ b/plugins/@sanity/rich-date-input/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts b/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
--- a/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
+++ b/plugins/@sanity/sanity-plugin-async-list/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/sfcc/vitest.config.ts b/plugins/@sanity/sfcc/vitest.config.ts
--- a/plugins/@sanity/sfcc/vitest.config.ts
+++ b/plugins/@sanity/sfcc/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/studio-secrets/vitest.config.ts b/plugins/@sanity/studio-secrets/vitest.config.ts
--- a/plugins/@sanity/studio-secrets/vitest.config.ts
+++ b/plugins/@sanity/studio-secrets/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/table/vitest.config.ts b/plugins/@sanity/table/vitest.config.ts
--- a/plugins/@sanity/table/vitest.config.ts
+++ b/plugins/@sanity/table/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/@sanity/vercel-protection-bypass/vitest.config.ts b/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
--- a/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
+++ b/plugins/@sanity/vercel-protection-bypass/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-naive-html-serializer/vitest.config.ts b/plugins/sanity-naive-html-serializer/vitest.config.ts
--- a/plugins/sanity-naive-html-serializer/vitest.config.ts
+++ b/plugins/sanity-naive-html-serializer/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-aprimo/vitest.config.ts b/plugins/sanity-plugin-aprimo/vitest.config.ts
--- a/plugins/sanity-plugin-aprimo/vitest.config.ts
+++ b/plugins/sanity-plugin-aprimo/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts b/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
--- a/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
+++ b/plugins/sanity-plugin-asset-source-unsplash/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-bynder-input/vitest.config.ts b/plugins/sanity-plugin-bynder-input/vitest.config.ts
--- a/plugins/sanity-plugin-bynder-input/vitest.config.ts
+++ b/plugins/sanity-plugin-bynder-input/vitest.config.ts
@@ -11,9 +11,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-cloudinary/vitest.config.ts b/plugins/sanity-plugin-cloudinary/vitest.config.ts
--- a/plugins/sanity-plugin-cloudinary/vitest.config.ts
+++ b/plugins/sanity-plugin-cloudinary/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-document-list/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-netlify/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts b/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
--- a/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
+++ b/plugins/sanity-plugin-dashboard-widget-vercel/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-documents-pane/vitest.config.ts b/plugins/sanity-plugin-documents-pane/vitest.config.ts
--- a/plugins/sanity-plugin-documents-pane/vitest.config.ts
+++ b/plugins/sanity-plugin-documents-pane/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-google-translate/vitest.config.ts b/plugins/sanity-plugin-google-translate/vitest.config.ts
--- a/plugins/sanity-plugin-google-translate/vitest.config.ts
+++ b/plugins/sanity-plugin-google-translate/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-graph-view/vitest.config.ts b/plugins/sanity-plugin-graph-view/vitest.config.ts
--- a/plugins/sanity-plugin-graph-view/vitest.config.ts
+++ b/plugins/sanity-plugin-graph-view/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-hotspot-array/vitest.config.ts b/plugins/sanity-plugin-hotspot-array/vitest.config.ts
--- a/plugins/sanity-plugin-hotspot-array/vitest.config.ts
+++ b/plugins/sanity-plugin-hotspot-array/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-iframe-pane/vitest.config.ts b/plugins/sanity-plugin-iframe-pane/vitest.config.ts
--- a/plugins/sanity-plugin-iframe-pane/vitest.config.ts
+++ b/plugins/sanity-plugin-iframe-pane/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-internationalized-array/vitest.config.ts b/plugins/sanity-plugin-internationalized-array/vitest.config.ts
--- a/plugins/sanity-plugin-internationalized-array/vitest.config.ts
+++ b/plugins/sanity-plugin-internationalized-array/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-latex-input/vitest.config.ts b/plugins/sanity-plugin-latex-input/vitest.config.ts
--- a/plugins/sanity-plugin-latex-input/vitest.config.ts
+++ b/plugins/sanity-plugin-latex-input/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-markdown/vitest.config.ts b/plugins/sanity-plugin-markdown/vitest.config.ts
--- a/plugins/sanity-plugin-markdown/vitest.config.ts
+++ b/plugins/sanity-plugin-markdown/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-media/vitest.config.ts b/plugins/sanity-plugin-media/vitest.config.ts
--- a/plugins/sanity-plugin-media/vitest.config.ts
+++ b/plugins/sanity-plugin-media/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-mux-input/vitest.config.ts b/plugins/sanity-plugin-mux-input/vitest.config.ts
--- a/plugins/sanity-plugin-mux-input/vitest.config.ts
+++ b/plugins/sanity-plugin-mux-input/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-shopify-assets/vitest.config.ts b/plugins/sanity-plugin-shopify-assets/vitest.config.ts
--- a/plugins/sanity-plugin-shopify-assets/vitest.config.ts
+++ b/plugins/sanity-plugin-shopify-assets/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
+        // `import * as _jestDom` side-effect imports in Vitest setup files.
+        if (!/\.[tj]sx$/.test(filename) && !/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
           return null
         }
         const result = transformSync(filename, code, {

diff --git a/plugins/sanity-plugin-studio-smartling/vitest.config.ts b/plugins/sanity-plugin-studio-smartling/vitest.config.ts
--- a/plugins/sanity-plugin-studio-smartling/vitest.config.ts
+++ b/plugins/sanity-plugin-studio-smartling/vitest.config.ts
@@ -10,9 +10,10 @@
       filter: {id: {include: /\.[tj]sx?(?:\?|$)/, exclude: /\/node_modules\//}},
       handler(code: string, id: string) {
         const filename = id.includes('?') ? id.slice(0, id.indexOf('?')) : id
-        // Skip non-React modules. oxc DCE drops unused `import * as _jestDom`
-        // side-effect imports in Vitest setup files.
-        if (!/(?:from|import)\s*['"]react(?:['"]|\/)/.test(code)) {
+        // Skip non-React modules — but `.tsx`/`.jsx` files always are (the
+        // automatic JSX runtime needs no react import). oxc DCE drops unused
... diff truncated: showing 800 of 990 lines

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 249df77. Configure here.

Comment thread turbo/generators/templates/vitest.config.ts.hbs Outdated
Base automatically changed from cursor/react-compiler-oxc-transform-d575 to main August 20, 2026 14:52
@stipsan
stipsan marked this pull request as draft August 21, 2026 16:03
Add @sanity/plugin-kit/vitest exporting reactCompilerPluginForVitest(),
register it in every plugin vitest.config.ts so tests exercise the same
oxc-compiled output that tsdown ships, wire it into the generators, and
enforce the tsdown/Vitest pairing with scripts/react-compiler-parity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants