From 863bd81d0fb2467126770e050f387c46fd376a58 Mon Sep 17 00:00:00 2001 From: patak Date: Sun, 26 Mar 2023 20:36:21 +0200 Subject: [PATCH] chore: ignore foo?bar#baz --- packages/vite/src/node/plugins/resolve.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 3cd94801f324b3..fedef26b081855 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -484,15 +484,18 @@ function tryFsResolve( const hashIndex = fsPath.indexOf('#') if (hashIndex > 0 && isInNodeModules(fsPath)) { const queryIndex = fsPath.indexOf('?') - const file = queryIndex > hashIndex ? fsPath.slice(0, queryIndex) : fsPath - const res = tryCleanFsResolve( - file, - options, - tryIndex, - targetWeb, - skipPackageJson, - ) - if (res) return res + fsPath.slice(file.length) + // We only need to check foo#bar?baz and foo#bar, ignore foo?bar#baz + if (queryIndex < 0 || queryIndex > hashIndex) { + const file = queryIndex > hashIndex ? fsPath.slice(0, queryIndex) : fsPath + const res = tryCleanFsResolve( + file, + options, + tryIndex, + targetWeb, + skipPackageJson, + ) + if (res) return res + fsPath.slice(file.length) + } } const { file, postfix } = splitFileAndPostfix(fsPath)