From 2a519a176d9f499d2b2814cc08549e9985a048e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 15 Nov 2023 21:38:54 +0900 Subject: [PATCH] fix: don't append `/@fs/` for bare imports (#14995) --- packages/vite/src/node/plugins/importAnalysis.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index 528b68a221dcc5..08b827d4d8fb75 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -335,7 +335,8 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { url = resolved.id.slice(root.length) } else if ( depsOptimizer?.isOptimizedDepFile(resolved.id) || - fs.existsSync(cleanUrl(resolved.id)) + (path.isAbsolute(cleanUrl(resolved.id)) && + fs.existsSync(cleanUrl(resolved.id))) ) { // an optimized deps may not yet exists in the filesystem, or // a regular file exists but is out of root: rewrite to absolute /@fs/ paths