@@ -9,6 +9,7 @@ import { ViteNodeRunner } from 'vite-node/client'
9
9
import { SnapshotManager } from '@vitest/snapshot/manager'
10
10
import type { CancelReason , File } from '@vitest/runner'
11
11
import { ViteNodeServer } from 'vite-node/server'
12
+ import type { defineWorkspace } from 'vitest/config'
12
13
import type { ArgumentsType , CoverageProvider , OnServerRestartHandler , Reporter , ResolvedConfig , UserConfig , UserWorkspaceConfig , VitestRunMode } from '../types'
13
14
import { hasFailed , noop , slash , toArray } from '../utils'
14
15
import { getCoverageProvider } from '../integrations/coverage'
@@ -215,7 +216,7 @@ export class Vitest {
215
216
return [ await this . createCoreProject ( ) ]
216
217
217
218
const workspaceModule = await this . runner . executeFile ( workspaceConfigPath ) as {
218
- default : ( string | UserWorkspaceConfig ) [ ]
219
+ default : ReturnType < typeof defineWorkspace >
219
220
}
220
221
221
222
if ( ! workspaceModule . default || ! Array . isArray ( workspaceModule . default ) )
@@ -225,10 +226,20 @@ export class Vitest {
225
226
const projectsOptions : UserWorkspaceConfig [ ] = [ ]
226
227
227
228
for ( const project of workspaceModule . default ) {
228
- if ( typeof project === 'string' )
229
+ if ( typeof project === 'string' ) {
229
230
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
+ }
232
243
}
233
244
234
245
const globOptions : fg . Options = {
0 commit comments