Skip to content

Commit b62ac22

Browse files
authored
chore: use tinyglobby instead of fast-glob in Vitest (#7504)
1 parent 167a98d commit b62ac22

File tree

8 files changed

+55
-417
lines changed

8 files changed

+55
-417
lines changed

packages/vitest/LICENSE.md

+20-304
Large diffs are not rendered by default.

packages/vitest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@
193193
"birpc": "0.2.19",
194194
"cac": "^6.7.14",
195195
"chai-subset": "^1.6.0",
196-
"fast-glob": "3.3.3",
197196
"find-up": "^6.3.0",
198197
"flatted": "^3.3.2",
199198
"get-tsconfig": "^4.10.0",
@@ -204,6 +203,7 @@
204203
"pretty-format": "^29.7.0",
205204
"prompts": "^2.4.2",
206205
"strip-literal": "^2.1.1",
206+
"tinyglobby": "^0.2.10",
207207
"ws": "^8.18.0"
208208
}
209209
}

packages/vitest/rollup.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { fileURLToPath } from 'node:url'
44
import commonjs from '@rollup/plugin-commonjs'
55
import json from '@rollup/plugin-json'
66
import nodeResolve from '@rollup/plugin-node-resolve'
7-
import fg from 'fast-glob'
87
import { dirname, join, normalize, resolve } from 'pathe'
98
import { defineConfig } from 'rollup'
109
import dts from 'rollup-plugin-dts'
1110
import esbuild from 'rollup-plugin-esbuild'
1211
import license from 'rollup-plugin-license'
12+
import { globSync } from 'tinyglobby'
1313
import c from 'tinyrainbow'
1414

1515
const require = createRequire(import.meta.url)
@@ -199,8 +199,9 @@ function licensePlugin() {
199199
preserveSymlinks: false,
200200
}),
201201
)
202-
const [licenseFile] = fg.sync(`${pkgDir}/LICENSE*`, {
202+
const [licenseFile] = globSync(`${pkgDir}/LICENSE*`, {
203203
caseSensitiveMatch: false,
204+
expandDirectories: false,
204205
})
205206
if (licenseFile) {
206207
licenseText = fs.readFileSync(licenseFile, 'utf-8')

packages/vitest/src/node/project.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import { rm } from 'node:fs/promises'
2222
import { tmpdir } from 'node:os'
2323
import path from 'node:path'
2424
import { deepMerge, nanoid, slash } from '@vitest/utils'
25-
import fg from 'fast-glob'
2625
import mm from 'micromatch'
2726
import { isAbsolute, join, relative } from 'pathe'
27+
import { glob, type GlobOptions } from 'tinyglobby'
2828
import { ViteNodeRunner } from 'vite-node/client'
2929
import { ViteNodeServer } from 'vite-node/server'
3030
import { setup } from '../api/setup'
@@ -421,13 +421,14 @@ export class TestProject {
421421

422422
/** @internal */
423423
async globFiles(include: string[], exclude: string[], cwd: string) {
424-
const globOptions: fg.Options = {
424+
const globOptions: GlobOptions = {
425425
dot: true,
426426
cwd,
427427
ignore: exclude,
428+
expandDirectories: false,
428429
}
429430

430-
const files = await fg(include, globOptions)
431+
const files = await glob(include, globOptions)
431432
// keep the slashes consistent with Vite
432433
// we are not using the pathe here because it normalizes the drive letter on Windows
433434
// and we want to keep it the same as working dir

packages/vitest/src/node/workspace/fast-glob-pattern.ts

-77
This file was deleted.

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import { existsSync, promises as fs } from 'node:fs'
44
import os from 'node:os'
55
import { limitConcurrency } from '@vitest/runner/utils'
66
import { deepClone } from '@vitest/utils'
7-
import fg from 'fast-glob'
87
import { dirname, relative, resolve } from 'pathe'
8+
import { glob, type GlobOptions, isDynamicPattern } from 'tinyglobby'
99
import { mergeConfig } from 'vite'
1010
import { configFiles as defaultConfigFiles } from '../../constants'
1111
import { isTTY } from '../../utils/env'
1212
import { VitestFilteredOutProjectError } from '../errors'
1313
import { initializeProject, TestProject } from '../project'
1414
import { withLabel } from '../reporters/renderers/utils'
15-
import { isDynamicPattern } from './fast-glob-pattern'
1615

1716
export async function resolveWorkspace(
1817
vitest: Vitest,
@@ -397,14 +396,12 @@ async function resolveTestProjectConfigs(
397396
}
398397

399398
if (workspaceGlobMatches.length) {
400-
const globOptions: fg.Options = {
399+
const globOptions: GlobOptions = {
401400
absolute: true,
402401
dot: true,
403402
onlyFiles: false,
404403
cwd: vitest.config.root,
405-
markDirectories: true,
406-
// TODO: revert option when we go back to tinyglobby
407-
// expandDirectories: false,
404+
expandDirectories: false,
408405
ignore: [
409406
'**/node_modules/**',
410407
// temporary vite config file
@@ -414,7 +411,7 @@ async function resolveTestProjectConfigs(
414411
],
415412
}
416413

417-
const workspacesFs = await fg.glob(workspaceGlobMatches, globOptions)
414+
const workspacesFs = await glob(workspaceGlobMatches, globOptions)
418415

419416
await Promise.all(workspacesFs.map(async (path) => {
420417
// directories are allowed with a glob like `packages/*`

pnpm-lock.yaml

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/test/__snapshots__/list.test.ts.snap

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`basic output shows error 1`] = `
4-
"Error: top level error
5-
❯ top-level-error.test.ts:1:7
6-
1| throw new Error('top level error')
7-
| ^
8-
2|
9-
10-
Error: describe error
4+
"Error: describe error
115
❯ describe-error.test.ts:4:9
126
2|
137
3| describe('describe error', () => {
@@ -16,6 +10,12 @@ Error: describe error
1610
5|
1711
6| it('wont run', () => {
1812
13+
Error: top level error
14+
top-level-error.test.ts:1:7
15+
1| throw new Error('top level error')
16+
| ^
17+
2|
18+
1919
"
2020
`;
2121
@@ -60,13 +60,7 @@ math.test.ts > failing test
6060
`;
6161
6262
exports[`json output shows error 1`] = `
63-
"Error: top level error
64-
❯ top-level-error.test.ts:1:7
65-
1| throw new Error('top level error')
66-
| ^
67-
2|
68-
69-
Error: describe error
63+
"Error: describe error
7064
❯ describe-error.test.ts:4:9
7165
2|
7266
3| describe('describe error', () => {
@@ -75,17 +69,17 @@ Error: describe error
7569
5|
7670
6| it('wont run', () => {
7771
78-
"
79-
`;
80-
81-
exports[`json with a file output shows error 1`] = `
82-
"Error: top level error
72+
Error: top level error
8373
top-level-error.test.ts:1:7
8474
1| throw new Error('top level error')
8575
| ^
8676
2|
8777
88-
Error: describe error
78+
"
79+
`;
80+
81+
exports[`json with a file output shows error 1`] = `
82+
"Error: describe error
8983
❯ describe-error.test.ts:4:9
9084
2|
9185
3| describe('describe error', () => {
@@ -94,5 +88,11 @@ Error: describe error
9488
5|
9589
6| it('wont run', () => {
9690
91+
Error: top level error
92+
top-level-error.test.ts:1:7
93+
1| throw new Error('top level error')
94+
| ^
95+
2|
96+
9797
"
9898
`;

0 commit comments

Comments
 (0)