Skip to content

Commit

Permalink
fix: opt-in server.fs.cachedChecks (#17807)
Browse files Browse the repository at this point in the history
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
  • Loading branch information
patak-dev and bluwy committed Aug 1, 2024
1 parent 720447e commit 4de659c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit 4de659c

Please sign in to comment.