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 }, ),