From 052a18c5abb3e86c335fb072d6e9a0bfa5101073 Mon Sep 17 00:00:00 2001 From: bluwy Date: Tue, 23 Jul 2024 14:52:31 +0800 Subject: [PATCH] refactor: better fix --- packages/vite/src/node/plugins/importMetaGlob.ts | 7 +------ packages/vite/src/node/plugins/resolve.ts | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/vite/src/node/plugins/importMetaGlob.ts b/packages/vite/src/node/plugins/importMetaGlob.ts index 14d96a6aede5ca..d596d39d1a62e9 100644 --- a/packages/vite/src/node/plugins/importMetaGlob.ts +++ b/packages/vite/src/node/plugins/importMetaGlob.ts @@ -563,12 +563,7 @@ export async function toAbsoluteGlob( custom: { 'vite:import-glob': { isSubImportsPattern } }, })) || glob, ) - // If matching a subpath import, the returned path is relative and doesn't look absolute. - // If it matches an alias that starts with `#`, the path will be absolute. - if (isSubImportsPattern && !isAbsolute(resolved)) { - return join(root, resolved) - } - if (isSubImportsPattern || isAbsolute(resolved)) { + if (isAbsolute(resolved)) { return pre + globSafeResolvedPath(resolved, glob) } diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index ccffd1c152972c..d31b40dd7a7cbd 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -203,7 +203,7 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin { id = resolvedImports if (resolveOpts.custom?.['vite:import-glob']?.isSubImportsPattern) { - return id + return normalizePath(path.join(root, id)) } }