From 52e61986a82fcfb14cebb52b18da216cdc488eb7 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Tue, 20 Feb 2024 21:21:29 +0900 Subject: [PATCH] fix: resolve directory correctly when `fs.cachedChecks: true` --- packages/vite/src/node/fsUtils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/vite/src/node/fsUtils.ts b/packages/vite/src/node/fsUtils.ts index ae1892e989677c..9536218c8f8ce4 100644 --- a/packages/vite/src/node/fsUtils.ts +++ b/packages/vite/src/node/fsUtils.ts @@ -189,6 +189,10 @@ export function createCachedFsUtils(config: ResolvedConfig): FsUtils { function getDirentCacheFromPath( normalizedFile: string, ): DirentCache | false | undefined { + // path.posix.normalize may return a path either with / or without / + if (normalizedFile[normalizedFile.length - 1] === '/') { + normalizedFile = normalizedFile.slice(0, -1) + } if (normalizedFile === root) { return rootCache }