Skip to content

Commit 1b822d0

Browse files
authored
fix: ensure version query for relative node_modules imports (#10016)
1 parent a7706d0 commit 1b822d0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/vite/src/node/plugins/resolve.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {
175175
// as if they would have been imported through a bare import
176176
// Use the original id to do the check as the resolved id may be the real
177177
// file path after symlinks resolution
178-
const isNodeModule = !!normalizePath(id).match(nodeModulesInPathRE)
178+
const isNodeModule =
179+
nodeModulesInPathRE.test(normalizePath(id)) ||
180+
nodeModulesInPathRE.test(normalizePath(resolved))
181+
179182
if (isNodeModule && !resolved.match(DEP_VERSION_RE)) {
180183
const versionHash = depsOptimizer.metadata.browserHash
181184
if (versionHash && OPTIMIZABLE_ENTRY_RE.test(resolved)) {

0 commit comments

Comments
 (0)