From c49af2340b026f55b5855343c59272a9a733bd2f Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 6 Apr 2023 22:47:21 +0200 Subject: [PATCH] perf(resolve): reduce vite client path checks (#12471) --- packages/vite/src/node/config.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index f8349751505fa8..f4816167fa05e7 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -48,6 +48,7 @@ import { DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, ENV_ENTRY, + FS_PREFIX, } from './constants' import type { InternalResolveOptions, @@ -475,8 +476,14 @@ export async function resolveConfig( ) const clientAlias = [ - { find: /^\/?@vite\/env/, replacement: ENV_ENTRY }, - { find: /^\/?@vite\/client/, replacement: CLIENT_ENTRY }, + { + find: /^\/?@vite\/env/, + replacement: path.posix.join(FS_PREFIX, normalizePath(ENV_ENTRY)), + }, + { + find: /^\/?@vite\/client/, + replacement: path.posix.join(FS_PREFIX, normalizePath(CLIENT_ENTRY)), + }, ] // resolve alias with internal client alias