From 3ef8aaa7e5979dfe2fc3ec81391bd21f36c09097 Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 6 Apr 2023 21:56:59 +0200 Subject: [PATCH] perf(resolve): avoid tryFsResolve for /@fs/ paths (#12450) --- packages/vite/src/node/plugins/resolve.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 8d5b29947799c5..626b5909644700 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -206,12 +206,12 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin { // explicit fs paths that starts with /@fs/* if (asSrc && id.startsWith(FS_PREFIX)) { - const fsPath = fsPathFromId(id) - res = tryFsResolve(fsPath, options) - debug?.(`[@fs] ${colors.cyan(id)} -> ${colors.dim(res)}`) + res = fsPathFromId(id) + // We don't need to resolve these paths since they are already resolved // always return here even if res doesn't exist since /@fs/ is explicit - // if the file doesn't exist it should be a 404 - return ensureVersionQuery(res || fsPath, id, options, depsOptimizer) + // if the file doesn't exist it should be a 404. + debug?.(`[@fs] ${colors.cyan(id)} -> ${colors.dim(res)}`) + return ensureVersionQuery(res, id, options, depsOptimizer) } // URL