Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,16 @@ The package-exports test resolves the workspace `exports` map, whose `.` entry p
the workspace's `vitest.config.ts`:

```ts
import pluginBabel from '@rolldown/plugin-babel'
import {vanillaExtractPlugin} from '@sanity/vanilla-extract-vite-plugin'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
plugins: [vanillaExtractPlugin()],
// 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()],
oxc: {jsx: {runtime: 'automatic'}},
// ...existing test config
})
```
Expand Down Expand Up @@ -282,7 +287,7 @@ Migrate styling from styled-components to vanilla-extract (zero-runtime CSS)
- [ ] `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()`
- [ ] `vitest.config.ts` registers `vanillaExtractPlugin()` **alongside** the existing React Compiler babel plugin (`pluginBabel({presets: [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
Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/plugin-test-coverage/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Skip one-off tooling (migrations, banners) unless they are part of the main auth
- 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 — do not add unnecessary `useMemo` / `useCallback`.
- 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`.

Run a single package:

Expand Down
2 changes: 2 additions & 0 deletions .agents/skills/plugin-transfer/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Keep and maintain these monorepo config files in the transferred plugin:
- `tsconfig.json`
- `vitest.config.ts`

The copy-plugin generator sets `reactCompiler: true` in `tsdown.config.ts` and mirrors it in `vitest.config.ts` via `@rolldown/plugin-babel` + `reactCompilerPreset`. Keep that Vitest wiring — tests must exercise compiled output. See AGENTS.md (“React Compiler Vitest parity”).

Do not copy standalone-repo-only setup such as custom root CI/build/lint/test configs that are already handled by this monorepo.

## Clean Up the Transferred README
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ drop-in match:

```ts
// plugins/@sanity/google-maps-input/vitest.config.ts
import pluginBabel from '@rolldown/plugin-babel'
import {vanillaExtractPlugin} from '@sanity/vanilla-extract-vite-plugin'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
plugins: [vanillaExtractPlugin()],
// Keep React Compiler (matches tsdown `reactCompiler: true`) and compose VE.
plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
oxc: {jsx: {runtime: 'automatic'}},
// ...
})
```
Expand All @@ -234,11 +238,14 @@ in `setupFiles` (the generator emits it when you opt into styling):

```ts
// vitest.config.ts
import pluginBabel from '@rolldown/plugin-babel'
import {vanillaExtractPlugin} from '@sanity/vanilla-extract-vite-plugin'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
plugins: [vanillaExtractPlugin()],
plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
oxc: {jsx: {runtime: 'automatic'}},
test: {
setupFiles: ['@vanilla-extract/css/disableRuntimeStyles'],
// ...
Expand Down
18 changes: 18 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,24 @@ Use numeric separators (`30_000` instead of `30000`) for readability.
- Root Vitest sets `SC_DISABLE_SPEEDY=false` so styled-components keeps its fast CSSOM injection path under jsdom (upstream disables it when `NODE_ENV !== 'production'`, which makes first mounts of styled-heavy trees slow enough to trip default timeouts). Same approach as [sanity#13675](https://github.com/sanity-io/sanity/pull/13675).
- For plugins that use vanilla-extract: register `vanillaExtractPlugin()` in the plugin’s `vitest.config.ts` (required so `.css.ts` compiles under Vitest) and include `'@vanilla-extract/css/disableRuntimeStyles'` in `setupFiles` (no-op under `node`, skips CSS injection for `jsdom`/`happy-dom` suites; remove only when a test asserts real CSS) — see the `sanity-plugin-best-practices` styling reference (`Disabling runtime styles in tests`)

### React Compiler Vitest parity

If a plugin’s `tsdown.config.ts` has `reactCompiler: true` (the default from generators), its `vitest.config.ts` **must** register the same Babel stack so unit tests exercise compiled output — not uncompiled `src`:

```ts
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'

export default defineConfig({
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {jsx: {runtime: 'automatic'}},
// ...
})
```

- Generators already wire both `tsdown.config.ts` and `vitest.config.ts` (plus `@rolldown/plugin-babel` / `@vitejs/plugin-react` catalog deps). Do not remove the Vitest compiler plugin when adding vanilla-extract or other plugins — compose into `plugins: [...]`.
- `scripts/react-compiler-parity` enforces this invariant in `pnpm test`. Agents who enable or keep `reactCompiler` in tsdown without mirroring Vitest will fail CI.

## Pull Request Workflow

### 1. Create as Draft PR First
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/assist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@
"rxjs-exhaustmap-with-trailing": "^2.1.1"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/schema": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@types/lodash-es": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
Expand Down
7 changes: 7 additions & 0 deletions plugins/@sanity/assist/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
server: {
deps: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/block-insert-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@
},
"devDependencies": {
"@portabletext/editor": "^7.10.13",
"@rolldown/plugin-babel": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@testing-library/react": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"jsdom": "catalog:",
"react": "catalog:",
Expand Down
7 changes: 7 additions & 0 deletions plugins/@sanity/block-insert-picker/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
environment: 'jsdom',
server: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/code-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@
"@uiw/react-codemirror": "^4.25.11"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"react": "catalog:",
"sanity": "catalog:",
Expand Down
7 changes: 7 additions & 0 deletions plugins/@sanity/code-input/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
server: {
deps: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/color-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"tinycolor2": "^1.6.0"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@sanity/vanilla-extract-vite-plugin": "catalog:",
Expand All @@ -71,6 +72,7 @@
"@types/react": "catalog:",
"@types/tinycolor2": "^1.4.6",
"@vanilla-extract/css": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"react": "catalog:",
"sanity": "catalog:",
Expand Down
8 changes: 7 additions & 1 deletion plugins/@sanity/color-input/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import pluginBabel from '@rolldown/plugin-babel'
import {vanillaExtractPlugin} from '@sanity/vanilla-extract-vite-plugin'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
plugins: [vanillaExtractPlugin()],
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]}), vanillaExtractPlugin()],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
setupFiles: ['@vanilla-extract/css/disableRuntimeStyles'],
server: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/cross-dataset-duplicator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@
"dset": "^3.1.4"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/client": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
Expand Down
7 changes: 7 additions & 0 deletions plugins/@sanity/cross-dataset-duplicator/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
server: {
deps: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@
"rxjs": "catalog:"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
Expand Down
7 changes: 7 additions & 0 deletions plugins/@sanity/dashboard/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
server: {
deps: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/debug-live-sync-tags/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
"@sanity/ui": "catalog:"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
Expand Down
7 changes: 7 additions & 0 deletions plugins/@sanity/debug-live-sync-tags/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
server: {
deps: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/document-internationalization/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@
"sanity-plugin-utils": "workspace:^"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@testing-library/jest-dom": "catalog:",
"@testing-library/react": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"jsdom": "catalog:",
"react": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
environment: 'jsdom',
setupFiles: ['./src/test/setup.ts'],
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/embeddings-index-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
"react-rx": "^4.2.5"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
Expand Down
7 changes: 7 additions & 0 deletions plugins/@sanity/embeddings-index-ui/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
server: {
deps: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/@sanity/form-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
"react-icons": "catalog:"
},
"devDependencies": {
"@rolldown/plugin-babel": "catalog:",
"@sanity/tsconfig": "catalog:",
"@sanity/tsdown-config": "catalog:",
"@testing-library/react": "catalog:",
"@types/mailchimp__mailchimp_marketing": "^3.0.22",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"jsdom": "catalog:",
"react": "catalog:",
Expand Down
7 changes: 7 additions & 0 deletions plugins/@sanity/form-toolkit/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import pluginBabel from '@rolldown/plugin-babel'
import {reactCompilerPreset} from '@vitejs/plugin-react'
import {defineConfig} from 'vitest/config'

export default defineConfig({
// Match `reactCompiler: true` in tsdown.config.ts so tests exercise compiled output.
plugins: [pluginBabel({presets: [reactCompilerPreset()]})],
oxc: {
jsx: {runtime: 'automatic'},
},
test: {
// Component tests opt into jsdom per-file via `// @vitest-environment jsdom`.
// The default stays `node` so the package-exports test keeps resolving `sanity`
Expand Down
Loading
Loading