Skip to content

Commit 9070be3

Browse files
authored
fix: disable fs.cachedChecks for custom watch ignore patterns (#15828)
1 parent 1c0dc3d commit 9070be3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/vite/src/node/fsUtils.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ const cachedFsUtilsMap = new WeakMap<ResolvedConfig, FsUtils>()
4545
export function getFsUtils(config: ResolvedConfig): FsUtils {
4646
let fsUtils = cachedFsUtilsMap.get(config)
4747
if (!fsUtils) {
48-
if (config.command !== 'serve' || !config.server.fs.cachedChecks) {
49-
// cached fsUtils is only used in the dev server for now, and only when the watcher isn't configured
50-
// we can support custom ignored patterns later
48+
if (
49+
config.command !== 'serve' ||
50+
config.server.fs.cachedChecks === false ||
51+
config.server.watch?.ignored
52+
) {
53+
// cached fsUtils is only used in the dev server for now
54+
// it is enabled by default only when there aren't custom watcher ignored patterns configured
5155
fsUtils = commonFsUtils
5256
} else if (
5357
!config.resolve.preserveSymlinks &&

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ export interface FileSystemServeOptions {
194194
deny?: string[]
195195

196196
/**
197-
* Enable caching of fs calls.
197+
* Enable caching of fs calls. It is enabled by default if no custom watch ignored patterns are provided.
198198
*
199199
* @experimental
200-
* @default true
200+
* @default undefined
201201
*/
202202
cachedChecks?: boolean
203203
}
@@ -1002,7 +1002,7 @@ export function resolveServerOptions(
10021002
strict: server.fs?.strict ?? true,
10031003
allow: allowDirs,
10041004
deny,
1005-
cachedChecks: server.fs?.cachedChecks ?? true,
1005+
cachedChecks: server.fs?.cachedChecks,
10061006
}
10071007

10081008
if (server.origin?.endsWith('/')) {

0 commit comments

Comments
 (0)