@@ -9,6 +9,7 @@ import { ViteNodeRunner } from 'vite-node/client'
99import { SnapshotManager } from '@vitest/snapshot/manager'
1010import type { CancelReason , File } from '@vitest/runner'
1111import { ViteNodeServer } from 'vite-node/server'
12+ import type { defineWorkspace } from 'vitest/config'
1213import type { ArgumentsType , CoverageProvider , OnServerRestartHandler , Reporter , ResolvedConfig , UserConfig , UserWorkspaceConfig , VitestRunMode } from '../types'
1314import { hasFailed , noop , slash , toArray } from '../utils'
1415import { getCoverageProvider } from '../integrations/coverage'
@@ -215,7 +216,7 @@ export class Vitest {
215216 return [ await this . createCoreProject ( ) ]
216217
217218 const workspaceModule = await this . runner . executeFile ( workspaceConfigPath ) as {
218- default : ( string | UserWorkspaceConfig ) [ ]
219+ default : ReturnType < typeof defineWorkspace >
219220 }
220221
221222 if ( ! workspaceModule . default || ! Array . isArray ( workspaceModule . default ) )
@@ -225,10 +226,20 @@ export class Vitest {
225226 const projectsOptions : UserWorkspaceConfig [ ] = [ ]
226227
227228 for ( const project of workspaceModule . default ) {
228- if ( typeof project === 'string' )
229+ if ( typeof project === 'string' ) {
229230 workspaceGlobMatches . push ( project . replace ( '<rootDir>' , this . config . root ) )
230- else
231- projectsOptions . push ( project )
231+ }
232+ else if ( typeof project === 'function' ) {
233+ projectsOptions . push ( await project ( {
234+ command : this . server . config . command ,
235+ mode : this . server . config . mode ,
236+ isPreview : false ,
237+ isSsrBuild : false ,
238+ } ) )
239+ }
240+ else {
241+ projectsOptions . push ( await project )
242+ }
232243 }
233244
234245 const globOptions : fg . Options = {
0 commit comments