@@ -138,8 +138,10 @@ export function createPool(ctx: Vitest): ProcessPool {
138138
139139 let execArgv = projectExecArgvs . get ( project )
140140 if ( ! execArgv ) {
141+ const conditions = resolveConditions ( project )
141142 execArgv = [
142143 ...options . execArgv ,
144+ ...conditions ,
143145 ...project . config . execArgv ,
144146 ]
145147 projectExecArgvs . set ( project , execArgv )
@@ -236,36 +238,6 @@ export function createPool(ctx: Vitest): ProcessPool {
236238}
237239
238240function resolveOptions ( ctx : Vitest ) {
239- // in addition to resolve.conditions Vite also adds production/development,
240- // see: https://github.com/vitejs/vite/blob/af2aa09575229462635b7cbb6d248ca853057ba2/packages/vite/src/node/plugins/resolve.ts#L1056-L1080
241- const viteMajor = Number ( viteVersion . split ( '.' ) [ 0 ] )
242-
243- const potentialConditions = new Set ( viteMajor >= 6
244- ? ( ctx . vite . config . ssr . resolve ?. conditions ?? [ ] )
245- : [
246- 'production' ,
247- 'development' ,
248- ...ctx . vite . config . resolve . conditions ,
249- ] )
250-
251- const conditions = [ ...potentialConditions ]
252- . filter ( ( condition ) => {
253- if ( condition === 'production' ) {
254- return ctx . vite . config . isProduction
255- }
256- if ( condition === 'development' ) {
257- return ! ctx . vite . config . isProduction
258- }
259- return true
260- } )
261- . map ( ( condition ) => {
262- if ( viteMajor >= 6 && condition === 'development|production' ) {
263- return ctx . vite . config . isProduction ? 'production' : 'development'
264- }
265- return condition
266- } )
267- . flatMap ( c => [ '--conditions' , c ] )
268-
269241 // Instead of passing whole process.execArgv to the workers, pick allowed options.
270242 // Some options may crash worker, e.g. --prof, --title. nodejs/node#41103
271243 const execArgv = process . execArgv . filter (
@@ -278,7 +250,6 @@ function resolveOptions(ctx: Vitest) {
278250 const options : PoolProcessOptions = {
279251 execArgv : [
280252 ...execArgv ,
281- ...conditions ,
282253 '--experimental-import-meta-resolve' ,
283254 // https://github.com/vitest-dev/vitest/issues/8896
284255 ...( ( globalThis as any ) . Deno || process . versions . pnp ? [ ] : [ '--require' , suppressWarningsPath ] ) ,
@@ -295,6 +266,39 @@ function resolveOptions(ctx: Vitest) {
295266 return options
296267}
297268
269+ function resolveConditions ( project : TestProject ) {
270+ // in addition to resolve.conditions Vite also adds production/development,
271+ // see: https://github.com/vitejs/vite/blob/af2aa09575229462635b7cbb6d248ca853057ba2/packages/vite/src/node/plugins/resolve.ts#L1056-L1080
272+ const viteMajor = Number ( viteVersion . split ( '.' ) [ 0 ] )
273+ const viteConfig = project . vite . config
274+
275+ const potentialConditions = new Set ( viteMajor >= 6
276+ ? ( viteConfig . ssr . resolve ?. conditions ?? [ ] )
277+ : [
278+ 'production' ,
279+ 'development' ,
280+ ...( viteConfig . resolve . conditions ?? [ ] ) ,
281+ ] )
282+
283+ return [ ...potentialConditions ]
284+ . filter ( ( condition ) => {
285+ if ( condition === 'production' ) {
286+ return viteConfig . isProduction
287+ }
288+ if ( condition === 'development' ) {
289+ return ! viteConfig . isProduction
290+ }
291+ return true
292+ } )
293+ . map ( ( condition ) => {
294+ if ( viteMajor >= 6 && condition === 'development|production' ) {
295+ return viteConfig . isProduction ? 'production' : 'development'
296+ }
297+ return condition
298+ } )
299+ . flatMap ( c => [ '--conditions' , c ] )
300+ }
301+
298302function resolveMaxWorkers ( project : TestProject ) {
299303 if ( project . config . maxWorkers ) {
300304 return project . config . maxWorkers
0 commit comments