Skip to content

Commit 70baaaa

Browse files
authored
fix(vitest): use fast-glob instead of tinyglobby in Vitest (#6688)
1 parent 502ecbf commit 70baaaa

File tree

7 files changed

+404
-112
lines changed

7 files changed

+404
-112
lines changed

packages/vitest/LICENSE.md

Lines changed: 320 additions & 30 deletions
Large diffs are not rendered by default.

packages/vitest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
"chai-subset": "^1.6.0",
191191
"cli-truncate": "^4.0.0",
192192
"expect-type": "^0.19.0",
193+
"fast-glob": "3.3.2",
193194
"find-up": "^6.3.0",
194195
"flatted": "^3.3.1",
195196
"get-tsconfig": "^4.7.6",
@@ -201,7 +202,6 @@
201202
"pretty-format": "^29.7.0",
202203
"prompts": "^2.4.2",
203204
"strip-literal": "^2.1.0",
204-
"tinyglobby": "^0.2.6",
205205
"ws": "^8.18.0"
206206
}
207207
}

packages/vitest/rollup.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import nodeResolve from '@rollup/plugin-node-resolve'
88
import commonjs from '@rollup/plugin-commonjs'
99
import json from '@rollup/plugin-json'
1010
import license from 'rollup-plugin-license'
11-
import { globSync } from 'tinyglobby'
11+
import fg from 'fast-glob'
1212
import c from 'tinyrainbow'
1313
import { defineConfig } from 'rollup'
1414

@@ -198,8 +198,7 @@ function licensePlugin() {
198198
preserveSymlinks: false,
199199
}),
200200
)
201-
const [licenseFile] = globSync([`${pkgDir}/LICENSE*`], {
202-
expandDirectories: false,
201+
const [licenseFile] = fg.sync(`${pkgDir}/LICENSE*`, {
203202
caseSensitiveMatch: false,
204203
})
205204
if (licenseFile) {

packages/vitest/src/node/workspace.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type {
1717
} from 'vite'
1818
import { ViteNodeRunner } from 'vite-node/client'
1919
import { ViteNodeServer } from 'vite-node/server'
20-
import { glob } from 'tinyglobby'
20+
import fg from 'fast-glob'
2121
import type { Typechecker } from '../typecheck/typechecker'
2222
import { deepMerge, nanoid } from '../utils/base'
2323
import { setup } from '../api/setup'
@@ -296,13 +296,14 @@ export class WorkspaceProject {
296296
}
297297

298298
async globFiles(include: string[], exclude: string[], cwd: string) {
299-
return glob(include, {
300-
absolute: true,
299+
const globOptions: fg.Options = {
301300
dot: true,
302301
cwd,
303302
ignore: exclude,
304-
expandDirectories: false,
305-
})
303+
}
304+
305+
const files = await fg(include, globOptions)
306+
return files.map(file => resolve(cwd, file))
306307
}
307308

308309
async isTargetFile(id: string, source?: string): Promise<boolean> {

packages/vitest/src/node/workspace/resolveWorkspace.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync, promises as fs } from 'node:fs'
22
import { isMainThread } from 'node:worker_threads'
33
import { dirname, relative, resolve } from 'pathe'
4-
import { type GlobOptions, glob } from 'tinyglobby'
4+
import fg from 'fast-glob'
55
import { mergeConfig } from 'vite'
66
import type { Vitest } from '../core'
77
import type { UserConfig, UserWorkspaceConfig, WorkspaceProjectConfiguration } from '../types/config'
@@ -209,12 +209,14 @@ async function resolveWorkspaceProjectConfigs(
209209
}
210210

211211
if (workspaceGlobMatches.length) {
212-
const globOptions: GlobOptions = {
212+
const globOptions: fg.Options = {
213213
absolute: true,
214214
dot: true,
215215
onlyFiles: false,
216216
cwd: vitest.config.root,
217-
expandDirectories: false,
217+
markDirectories: true,
218+
// TODO: revert option when we go back to tinyglobby
219+
// expandDirectories: false,
218220
ignore: [
219221
'**/node_modules/**',
220222
// temporary vite config file
@@ -224,7 +226,7 @@ async function resolveWorkspaceProjectConfigs(
224226
],
225227
}
226228

227-
const workspacesFs = await glob(workspaceGlobMatches, globOptions)
229+
const workspacesFs = await fg.glob(workspaceGlobMatches, globOptions)
228230

229231
await Promise.all(workspacesFs.map(async (filepath) => {
230232
// directories are allowed with a glob like `packages/*`

0 commit comments

Comments
 (0)