From b1d6211d8df4f33172766a56ed87bd8d37648fbb Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 12 Dec 2023 18:42:06 +0100 Subject: [PATCH] perf: temporary hack to avoid fs checks for /@react-refresh (#15299) --- packages/vite/src/node/plugins/importAnalysis.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index 575eeeb35646ae..29e2819cf48ac8 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -338,7 +338,11 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { url = resolved.id.slice(root.length) } else if ( depsOptimizer?.isOptimizedDepFile(resolved.id) || - (path.isAbsolute(cleanUrl(resolved.id)) && + // vite-plugin-react isn't following the leading \0 virtual module convention. + // This is a temporary hack to avoid expensive fs checks for React apps. + // We'll remove this as soon we're able to fix the react plugins. + (resolved.id !== '/@react-refresh' && + path.isAbsolute(resolved.id) && fsUtils.existsSync(cleanUrl(resolved.id))) ) { // an optimized deps may not yet exists in the filesystem, or