From 57f7d866ed4acca153efa9688a8d86c6bc97d54b Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 16 Mar 2023 22:08:10 +0100 Subject: [PATCH 1/2] refactor: avoid tryFsResolve for /@fs/ paths --- packages/vite/src/node/plugins/resolve.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 4cdd2043cc41b7..ac32fceab77c56 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -245,12 +245,11 @@ 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) + res = fsPathFromId(id) isDebug && debug(`[@fs] ${colors.cyan(id)} -> ${colors.dim(res)}`) // 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) + return ensureVersionQuery(res) } // URL From 99ceda39b56c472442538f3f34ff737dabbbf32c Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 6 Apr 2023 21:17:14 +0200 Subject: [PATCH 2/2] chore: update comment --- packages/vite/src/node/plugins/resolve.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 9ea69d401316e9..0ed3278396e24a 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -208,9 +208,10 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin { // explicit fs paths that starts with /@fs/* if (asSrc && id.startsWith(FS_PREFIX)) { res = fsPathFromId(id) - debug?.(`[@fs] ${colors.cyan(id)} -> ${colors.dim(res)}`) + // 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 + // 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) }