Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable fs.cachedChecks by default #15704

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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