Skip to content

Commit 4de659c

Browse files
patak-devbluwy
andauthored
fix: opt-in server.fs.cachedChecks (#17807)
Co-authored-by: Bjorn Lu <[email protected]>
1 parent 720447e commit 4de659c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

docs/config/server-options.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ export default defineConfig({
328328

329329
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.
330330

331+
## server.fs.cachedChecks
332+
333+
- **Type:** `boolean`
334+
- **Default:** `false`
335+
- **Experimental**
336+
337+
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.
338+
331339
## server.origin
332340

333341
- **Type:** `string`

packages/vite/src/node/fsUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ export function getFsUtils(config: ResolvedConfig): FsUtils {
4646
if (!fsUtils) {
4747
if (
4848
config.command !== 'serve' ||
49-
config.server.fs.cachedChecks === false ||
49+
config.server.fs.cachedChecks !== true ||
5050
config.server.watch?.ignored ||
5151
process.versions.pnp
5252
) {
5353
// cached fsUtils is only used in the dev server for now
54-
// it is enabled by default only when there aren't custom watcher ignored patterns configured
54+
// it is disabled by default due to potential edge cases when writing a file
55+
// and reading it immediately
56+
// It is also disabled when there aren't custom watcher ignored patterns configured
5557
// and if yarn pnp isn't used
5658
fsUtils = commonFsUtils
5759
} else if (

0 commit comments

Comments
 (0)