Skip to content

Commit

Permalink
fix: disable fs.cachedChecks for custom watch ignore patterns (#15828)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Feb 7, 2024
1 parent 1c0dc3d commit 9070be3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions packages/vite/src/node/fsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ const cachedFsUtilsMap = new WeakMap<ResolvedConfig, FsUtils>()
export function getFsUtils(config: ResolvedConfig): FsUtils {
let fsUtils = cachedFsUtilsMap.get(config)
if (!fsUtils) {
if (config.command !== 'serve' || !config.server.fs.cachedChecks) {
// cached fsUtils is only used in the dev server for now, and only when the watcher isn't configured
// we can support custom ignored patterns later
if (
config.command !== 'serve' ||
config.server.fs.cachedChecks === false ||
config.server.watch?.ignored
) {
// cached fsUtils is only used in the dev server for now
// it is enabled by default only when there aren't custom watcher ignored patterns configured
fsUtils = commonFsUtils
} else if (
!config.resolve.preserveSymlinks &&
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ export interface FileSystemServeOptions {
deny?: string[]

/**
* Enable caching of fs calls.
* Enable caching of fs calls. It is enabled by default if no custom watch ignored patterns are provided.
*
* @experimental
* @default true
* @default undefined
*/
cachedChecks?: boolean
}
Expand Down Expand Up @@ -1002,7 +1002,7 @@ export function resolveServerOptions(
strict: server.fs?.strict ?? true,
allow: allowDirs,
deny,
cachedChecks: server.fs?.cachedChecks ?? true,
cachedChecks: server.fs?.cachedChecks,
}

if (server.origin?.endsWith('/')) {
Expand Down

0 comments on commit 9070be3

Please sign in to comment.