From 51af123e07d058c3f5612eba78c3a7d2e3949173 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 24 Jan 2024 07:04:13 +0100 Subject: [PATCH 1/2] feat: enable fs.cachedChecks by default --- packages/vite/src/node/fsUtils.ts | 19 +------------------ packages/vite/src/node/server/index.ts | 5 ++--- playground/html/vite.config.js | 2 +- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/packages/vite/src/node/fsUtils.ts b/packages/vite/src/node/fsUtils.ts index ec9c6431bfa645..f419a7bd7619b1 100644 --- a/packages/vite/src/node/fsUtils.ts +++ b/packages/vite/src/node/fsUtils.ts @@ -49,27 +49,10 @@ export function getFsUtils(config: ResolvedConfig): FsUtils { // 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 fsUtils = commonFsUtils - } /* TODO: Enabling for testing, we need to review if this guard is needed - else if (config.server.watch === null || config.server.watch?.ignored) { - config.logger.warn( - colors.yellow( - `${colors.bold( - `(!)`, - )} server.fs.cachedChecks isn't supported if server.watch is null or a custom server.watch.ignored is configured\n`, - ), - ) - fsUtils = commonFsUtils - } */ else if ( + } else if ( !config.resolve.preserveSymlinks && config.root !== getRealPath(config.root) ) { - config.logger.warn( - colors.yellow( - `${colors.bold( - `(!)`, - )} server.fs.cachedChecks isn't supported when resolve.preserveSymlinks is false and root is symlinked\n`, - ), - ) fsUtils = commonFsUtils } else { fsUtils = createCachedFsUtils(config) diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 973c026dd42a69..7f8c08e2f3df11 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -194,7 +194,7 @@ export interface FileSystemServeOptions { * Enable caching of fs calls. * * @experimental - * @default false + * @default true */ cachedChecks?: boolean } @@ -989,8 +989,7 @@ export function resolveServerOptions( strict: server.fs?.strict ?? true, allow: allowDirs, deny, - cachedChecks: - server.fs?.cachedChecks ?? !!process.env.VITE_SERVER_FS_CACHED_CHECKS, + cachedChecks: server.fs?.cachedChecks ?? true, } if (server.origin?.endsWith('/')) { diff --git a/playground/html/vite.config.js b/playground/html/vite.config.js index b1e51226e078bd..003a591def4c1d 100644 --- a/playground/html/vite.config.js +++ b/playground/html/vite.config.js @@ -46,7 +46,7 @@ export default defineConfig({ server: { fs: { - cachedChecks: true, + cachedChecks: false, }, warmup: { clientFiles: ['./warmup/*'], From c4d4ce73881a81d746159ab22c355c0a12c66d9f Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 24 Jan 2024 07:12:54 +0100 Subject: [PATCH 2/2] chore: update --- packages/vite/src/node/fsUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/vite/src/node/fsUtils.ts b/packages/vite/src/node/fsUtils.ts index f419a7bd7619b1..3cac75a7722e3f 100644 --- a/packages/vite/src/node/fsUtils.ts +++ b/packages/vite/src/node/fsUtils.ts @@ -1,6 +1,5 @@ import fs from 'node:fs' import path from 'node:path' -import colors from 'picocolors' import type { FSWatcher } from 'dep-types/chokidar' import type { ResolvedConfig } from './config' import {