@@ -4,6 +4,7 @@ import type { ResolvedConfig, TestProjectInlineConfiguration } from '../types/co
44import { existsSync , readFileSync } from 'node:fs'
55import { deepMerge } from '@vitest/utils'
66import { basename , dirname , relative , resolve } from 'pathe'
7+ import * as vite from 'vite'
78import { configDefaults } from '../../defaults'
89import { generateScopedClassName } from '../../integrations/css/css-modules'
910import { VitestFilteredOutProjectError } from '../errors'
@@ -117,7 +118,7 @@ export function WorkspaceVitestPlugin(
117118 const root = testConfig . root || viteConfig . root || options . root
118119
119120 const resolveOptions = getDefaultResolveOptions ( )
120- const config : ViteConfig = {
121+ let config : ViteConfig = {
121122 root,
122123 define : {
123124 // disable replacing `process.env.NODE_ENV` with static string by vite:client-inject
@@ -127,15 +128,6 @@ export function WorkspaceVitestPlugin(
127128 ...resolveOptions ,
128129 alias : testConfig . alias ,
129130 } ,
130- esbuild : viteConfig . esbuild === false
131- ? false
132- : {
133- // Lowest target Vitest supports is Node18
134- target : viteConfig . esbuild ?. target || 'node18' ,
135- sourcemap : 'external' ,
136- // Enables using ignore hint for coverage providers with @preserve keyword
137- legalComments : 'inline' ,
138- } ,
139131 server : {
140132 // disable watch mode in workspaces,
141133 // because it is handled by the top-level watcher
@@ -162,6 +154,35 @@ export function WorkspaceVitestPlugin(
162154 test : { } ,
163155 }
164156
157+ if ( 'rolldownVersion' in vite ) {
158+ config = {
159+ ...config ,
160+ // eslint-disable-next-line ts/ban-ts-comment
161+ // @ts -ignore rolldown-vite only
162+ oxc : viteConfig . oxc === false
163+ ? false
164+ : {
165+ // eslint-disable-next-line ts/ban-ts-comment
166+ // @ts -ignore rolldown-vite only
167+ target : viteConfig . oxc ?. target || 'node18' ,
168+ } ,
169+ }
170+ }
171+ else {
172+ config = {
173+ ...config ,
174+ esbuild : viteConfig . esbuild === false
175+ ? false
176+ : {
177+ // Lowest target Vitest supports is Node18
178+ target : viteConfig . esbuild ?. target || 'node18' ,
179+ sourcemap : 'external' ,
180+ // Enables using ignore hint for coverage providers with @preserve keyword
181+ legalComments : 'inline' ,
182+ } ,
183+ }
184+ }
185+
165186 ; ( config . test as ResolvedConfig ) . defines = defines
166187
167188 const classNameStrategy
0 commit comments