From 8286c04dafd1b81f00a5accaca66661408c3a945 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 22 Nov 2024 20:16:07 +0900 Subject: [PATCH] perf: pass finalizeOtherSpecifiers when only needed --- packages/vite/src/node/plugins/resolve.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index d7cb690d74676f..1ebf572cc26762 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -308,9 +308,17 @@ export function oxcResolvePlugin( } return newId }, - finalizeOtherSpecifiers(resolvedId, rawId) { - return ensureVersionQuery(resolvedId, rawId, options, depsOptimizer) - }, + finalizeOtherSpecifiers: !depsOptimizer + ? undefined + : (resolvedId, rawId) => { + const newResolvedId = ensureVersionQuery( + resolvedId, + rawId, + options, + depsOptimizer, + ) + return newResolvedId === resolvedId ? undefined : newResolvedId + }, }) as unknown as Plugin }, ),