Skip to content

Commit

Permalink
feat: enable fs.cachedChecks by default (#15704)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Jan 25, 2024
1 parent 3a7b650 commit a05c709
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
20 changes: 1 addition & 19 deletions packages/vite/src/node/fsUtils.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -49,27 +48,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)
Expand Down
5 changes: 2 additions & 3 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export interface FileSystemServeOptions {
* Enable caching of fs calls.
*
* @experimental
* @default false
* @default true
*/
cachedChecks?: boolean
}
Expand Down Expand Up @@ -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('/')) {
Expand Down
2 changes: 1 addition & 1 deletion playground/html/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default defineConfig({

server: {
fs: {
cachedChecks: true,
cachedChecks: false,
},
warmup: {
clientFiles: ['./warmup/*'],
Expand Down

0 comments on commit a05c709

Please sign in to comment.