packages/vite/src/migrations/update-23-0-0/ai-instructions-for-vite-8.md
These instructions guide you through migrating an Nx workspace from Vite 7 to Vite 8. Vite 8 swaps Rollup for Rolldown as its bundler and updates a number of plugin APIs. Work through each section in order and run tests after each change.
Identify all Vite-using projects:
nx show projects --with-target build
nx show projects --with-target serve
Locate all Vite configuration files:
vite.config.{ts,js,mts,mjs,cts,cjs}project.json files for inline Vite-related optionsCypress Component Testing: Cypress >= 15.14.0 supports Vite 8. The nx migrate step bumps Cypress automatically. If you have explicitly pinned Cypress below 15.14.0, upgrade it before bumping Vite.
rollupOptions to rolldownOptionsThe nx migrate codemod handles this automatically for vite.config.{ts,js,mts,mjs,cts,cjs} files. If you have rollupOptions declared elsewhere (e.g., in helper modules imported by your config), rename them by hand.
Search Pattern: rollupOptions in any TypeScript/JavaScript file
// ❌ BEFORE (Vite 7)
export default defineConfig({
build: {
rollupOptions: {
external: ['react'],
output: { manualChunks: { vendor: ['react', 'react-dom'] } },
},
},
});
// ✅ AFTER (Vite 8)
export default defineConfig({
build: {
rolldownOptions: {
external: ['react'],
output: { manualChunks: { vendor: ['react', 'react-dom'] } },
},
},
});
Action Items:
rg "rollupOptions" should return zero hits inside vite configs)rollupOptions in helper modules or shared config buildersbuild.rollupOptions (e.g., custom bundle-size assertions)@vitejs/plugin-react v6 (Oxc Replaces Babel)@vitejs/plugin-react@^6 is required for Vite 8 and uses Oxc instead of Babel for JSX transformation. The plugin's babel option is gone.
// ❌ BEFORE (Vite 7, plugin-react v4)
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [
react({
babel: {
plugins: ['babel-plugin-styled-components'],
},
}),
],
});
// ✅ AFTER (Vite 8, plugin-react v6)
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
});
Action Items:
babel options from react() plugin invocations@vitejs/plugin-react-swc (still Babel-free). There is no drop-in for arbitrary Babel plugins.pnpm install (or your package manager equivalent) so the new plugin-react version resolves@oxc-project/runtimeAngular projects whose test target uses @nx/vitest:test (the vitest-analog setup wired by @analogjs/vite-plugin-angular) need @oxc-project/runtime declared in the workspace devDependencies.
@analogjs/vite-plugin-angular registers an angularVitestPlugin (active in test mode) whose transform hook matches @angular/* fesm2022 modules that contain async (plus any @angular/cdk file) and calls vite.transformWithOxc(code, id, { target: 'es2016', … }). The downlevel is deliberate: Zone.js relies on monkey-patching promise scheduling for fakeAsync and friends, which it cannot do on native async/await, so the plugin lowers them to a form Zone.js can intercept. With target: 'es2016', oxc emits the helpers as external @oxc-project/runtime/helpers/* imports (oxc's default HelperMode = 'Runtime'). Nothing in the upstream chain (analogjs, @angular/core, vite, rolldown) declares @oxc-project/runtime in a way that's resolvable from the consumer's workspace, so vite:import-analysis fails to resolve those imports unless the dep is added explicitly.
Angular projects whose test target uses @angular/build:unit-test or @nx/angular:unit-test (the vitest-angular path) do not need this dependency — that path doesn't load @analogjs/vite-plugin-angular, sets optimizeDeps.noDiscovery: true, and uses an in-memory test provider, so the downlevel transform that emits the helper imports never runs.
Search Pattern: Projects with test.executor set to @nx/vitest:test that also have @analogjs/vite-plugin-angular in their vite.config.*.
rg '"@nx/vitest:test"' --type json
rg '@analogjs/vite-plugin-angular' --type ts --type js
Action Items:
@oxc-project/runtime to root devDependencies (the Nx Angular generators do this automatically on the vitest-analog path; check legacy workspaces that pre-date that)pnpm install (or equivalent)moduleResolution: "node"Vite 8 ships its types only via conditional exports (it dropped the top-level types field that Vite 7 carried), which TypeScript cannot resolve under moduleResolution: "node". Symptoms include type errors on defineConfig, UserConfig, or plugin return types.
Action Items:
tsconfig*.json files: "moduleResolution": "bundler" (recommended) or "node16"/"nodenext"moduleResolution, narrow the impact with explicit as any casts at vite imports. The Nx-generated configs already do this in a handful of places.tsc --noEmit after the change to confirm types resolve cleanlyRolldown produces different chunk and module counts than Rollup for the same input. Custom build validation (e.g., "bundle has exactly N chunks") will need to be re-baselined.
Action Items:
If a project depends on a Babel plugin that has no Oxc equivalent, pin that project to Vite 7.
// package.json (workspace root)
{
"devDependencies": {
"vite": "^7.1.0",
"@vitejs/plugin-react": "^4.3.0",
},
}
If only some projects need to stay on 7 while the rest move to 8, use your package manager's overrides feature:
pnpm.overrides in root package.jsonoverrides/resolutionsAction Items:
nx run-many -t test -p PROJECT_NAME
nx affected -t build
nx serve PROJECT_NAME
Open the app and verify HMR still works for changes in source files.
nx prepush
rollupOptions references renamed to rolldownOptions@vitejs/plugin-react upgraded to v6 (or pinned to v4 with a documented reason)babel: { ... } options remain in react() calls (or those projects are pinned to Vite 7)@oxc-project/runtime in root devDependenciesnx migrate (>= 15.14.0 for Vite 8 support)tsc --noEmit passes on all affected projectsCannot find name 'rollupOptions' or build options ignoredSolution: Rename to rolldownOptions. Vite 8 still accepts rollupOptions as a deprecated alias (it copies the value to rolldownOptions and logs a deprecation warning), but mixing both at the same level may cause precedence surprises (rolldownOptions wins).
Solution: @vitejs/plugin-react@6 removed Babel. Find an Oxc-compatible alternative, switch to @vitejs/plugin-react-swc, or pin to Vite 7 + plugin-react v4.
Failed to resolve import "@oxc-project/runtime/helpers/..."Solution: Add @oxc-project/runtime to root devDependencies and reinstall. This only affects projects whose test target uses @nx/vitest:test (the vitest-analog setup); projects using @angular/build:unit-test / @nx/angular:unit-test are not affected.
defineConfig, UserConfig, or Plugin imports from viteSolution: Set moduleResolution: "bundler" in your tsconfig (or nodenext if you need Node-style resolution).
Solution: Confirm cypress >= 15.14.0 is installed (Vite 8 support landed in that release). nx migrate bumps Cypress automatically; if you pinned it lower in package.json, remove the pin and reinstall.
Solution: Rolldown chunks differently than Rollup. Re-baseline expected values.
# Vite config files
find . -name "vite.config.*" -not -path "*/node_modules/*"
# Cypress component testing setup
rg "@nx/(angular|react|next|remix)/plugins/component-testing"
# Babel plugin usage in plugin-react
rg "@vitejs/plugin-react.*babel|babel:\s*\{" --type ts --type js
# Angular projects with Vitest
rg "@angular/build" -l package.json
DO NOT
expect(true).toBe(true)react() plugin options without finding an equivalent for what they didWhen executing this migration: