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

fix: opt-in server.fs.cachedChecks #17807

Merged
merged 2 commits into from
Aug 1, 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
8 changes: 8 additions & 0 deletions docs/config/server-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ export default defineConfig({

Blocklist for sensitive files being restricted to be served by Vite dev server. This will have higher priority than [`server.fs.allow`](#server-fs-allow). [picomatch patterns](https://github.com/micromatch/picomatch#globbing-features) are supported.

## server.fs.cachedChecks

- **Type:** `boolean`
- **Default:** `false`
- **Experimental**

Caches filenames of accessed directories to avoid repeated filesystem operations. Particularly in Windows, this could result in a performance boost. It is disabled by default due to edge cases when writing a file in a cached folder and immediately importing it.

## server.origin

- **Type:** `string`
Expand Down
6 changes: 4 additions & 2 deletions packages/vite/src/node/fsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ export function getFsUtils(config: ResolvedConfig): FsUtils {
if (!fsUtils) {
if (
config.command !== 'serve' ||
config.server.fs.cachedChecks === false ||
config.server.fs.cachedChecks !== true ||
config.server.watch?.ignored ||
process.versions.pnp
) {
// 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
// it is disabled by default due to potential edge cases when writing a file
// and reading it immediately
// It is also disabled when there aren't custom watcher ignored patterns configured
// and if yarn pnp isn't used
fsUtils = commonFsUtils
} else if (
Expand Down