From 6f4224c8740c2d4aa09ed73e9e4adb05b87a2350 Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 12 Dec 2023 14:47:45 +0100 Subject: [PATCH] chore: only apply the workaround for /@react-refresh --- packages/vite/src/node/plugins/importAnalysis.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index a1a1b15d15f317..c28b86f6b291b2 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -337,10 +337,9 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { url = resolved.id.slice(root.length) } else if ( depsOptimizer?.isOptimizedDepFile(resolved.id) || - // resolved virtual id convention, ie /@vite/client, /@react-refresh, /@vite-plugin-pwa - // We don't support absolute paths starting with `/@` at the root of the file system to avoid - // expensive fs checks - (!resolved.id.startsWith('/@') && + // vite-plugin-react isn't following the leading \0 virtual module convention + // this is a temporal workaround to avoid expensive fs checks for it + (resolved.id !== '/@react-refresh' && path.isAbsolute(resolved.id) && fs.existsSync(cleanUrl(resolved.id))) ) {