Skip to content

Commit 677508b

Browse files
authored
perf: skip globbing for static path in warmup (#19107)
1 parent b178c90 commit 677508b

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

packages/vite/src/node/server/warmup.ts

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs/promises'
22
import path from 'node:path'
33
import colors from 'picocolors'
4-
import { glob } from 'tinyglobby'
4+
import { glob, isDynamicPattern } from 'tinyglobby'
55
import { FS_PREFIX } from '../constants'
66
import { normalizePath } from '../utils'
77
import type { ViteDevServer } from '../index'
@@ -72,10 +72,29 @@ function fileToUrl(file: string, root: string) {
7272

7373
async function mapFiles(files: string[], root: string) {
7474
if (!files.length) return []
75-
return await glob(files, {
76-
absolute: true,
77-
cwd: root,
78-
expandDirectories: false,
79-
ignore: ['**/.git/**', '**/node_modules/**'],
80-
})
75+
76+
const result: string[] = []
77+
const globs: string[] = []
78+
for (const file of files) {
79+
if (isDynamicPattern(file)) {
80+
globs.push(file)
81+
} else {
82+
if (path.isAbsolute(file)) {
83+
result.push(file)
84+
} else {
85+
result.push(path.resolve(root, file))
86+
}
87+
}
88+
}
89+
if (globs.length) {
90+
result.push(
91+
...(await glob(globs, {
92+
absolute: true,
93+
cwd: root,
94+
expandDirectories: false,
95+
ignore: ['**/.git/**', '**/node_modules/**'],
96+
})),
97+
)
98+
}
99+
return result
81100
}

0 commit comments

Comments
 (0)