You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(deps): replace @vanilla-extract/vite-plugin with @sanity/vanilla-extract-vite-plugin (#1590)
* chore(deps): replace @vanilla-extract/vite-plugin with @sanity/vanilla-extract-vite-plugin
Swap the vanilla-extract Vite plugin used by the test studio and
@sanity/google-maps-input's vitest config to @sanity/vanilla-extract-vite-plugin,
a Vite 8 rewrite with plugin hook filters and a caching compiler on Vite's
Environment API / ModuleRunner instead of the legacy vite-node. Bump tsdown to
^0.22.8 and @sanity/tsdown-config to ^0.17.0 alongside it.
google-maps-input's vitest.config.ts also needed a small stub plugin: its
dist/bundle.css.js Node/SSR shim matches the upstream cssFileFilter by
filename alone (*.css.js), which made the new plugin try to evaluate it as
real .css.ts source and throw ReferenceError: require is not defined via
ModuleRunner (vite-node tolerated this). The stub renames that module id away
from a .css.js shape before vanillaExtractPlugin() ever sees it.
Documented both the plugin swap and the shim workaround in the
sanity-plugin-best-practices skill and the new-plugin generator templates so
future vanilla-extract plugins get this for free.
* chore(deps): bump @sanity/tsdown-config to ^0.17.1, drop bundle.css.js shim workaround
@sanity/tsdown-config 0.17.1 (via @sanity/vanilla-extract-tsdown-plugin
0.2.1 / @sanity/vanilla-extract-rolldown-plugin 0.1.1) renames the
vanilla-extract Node/SSR compat shim from bundle.css.js to bundle-css.js so
it no longer matches vanillaExtractPlugin()'s cssFileFilter by filename
alone (sanity-io/pkg-utils#3043). That was the root cause of the
require-is-not-defined regression worked around in the previous commit, so
the stub-bundle-css-js-shim plugin is no longer needed.
Rebuilding @sanity/google-maps-input picked up the renamed dist/bundle-css.js
shim and auto-rewrote its package.json ./bundle.css export map (adding a
types condition too). Reverted the vitest.config.ts workaround and the
matching documentation/generator-template changes back to the plain
vanillaExtractPlugin() registration, now noted as a historical gotcha
instead of a live workaround.
* docs(test-studio): note that unstable_bundledDev breaks .css.ts HMR
Document the trade-off discovered while testing the vanilla-extract Vite
plugin swap: with unstable_bundledDev: true, editing a .css.ts file doesn't
hot-reload (a sanity dev restart is required), while plain .ts/.tsx HMR is
unaffected. Comment out the line for a session if fast CSS HMR is needed
(confirmed sub-10ms with it unset).
* docs(styling skill): trim verbose vanilla-extract setup section
The ./bundle.css export map (and its dist/bundle-css.js shim/types) is
generated and kept in sync automatically by @sanity/tsdown-config's
vanillaExtract option, so it doesn't need explaining or a JSON example to
copy. Simplify the vitest.config.ts guidance to why (@sanity/vanilla-extract-
vite-plugin is faster than upstream) without the ModuleRunner/hook-filter/
sanity-build internals. Drop the sanity.cli.ts snippet, since the test studio
already registers the plugin globally in this repo and doesn't need to be
touched per-plugin. Drop the bundle.css.js->bundle-css.js rename history
note, a one-off gotcha now fixed upstream rather than evergreen guidance.
* chore(deps): bump @sanity/tsdown-config to ^0.17.2, @sanity/vanilla-extract-vite-plugin to ^0.1.1
Both are latest-available patch releases (0.17.1 -> 0.17.2 pulls in
@sanity/vanilla-extract-tsdown-plugin 0.2.2 / @sanity/vanilla-extract-
rolldown-plugin 0.1.2; 0.1.0 -> 0.1.1 is the vite plugin's own patch).
tsdown stays at ^0.22.8, already the latest. Benchmarked in the next commit's
message to confirm this doesn't regress anything.
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
0 commit comments