Skip to content

Commit 30a41ff

Browse files
authoredApr 26, 2023
fix(resolve): deep import resolvedId error (#13010)
1 parent 08c1452 commit 30a41ff

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,15 @@ export function tryNodeResolve(
773773
}
774774
let resolvedId = id
775775
if (deepMatch && !pkg?.data.exports && path.extname(id) !== resolvedExt) {
776-
resolvedId = resolved.id.slice(resolved.id.indexOf(id))
777-
debug?.(`[processResult] ${colors.cyan(id)} -> ${colors.dim(resolvedId)}`)
776+
// id date-fns/locale
777+
// resolve.id ...date-fns/esm/locale/index.js
778+
const index = resolved.id.indexOf(id)
779+
if (index > -1) {
780+
resolvedId = resolved.id.slice(index)
781+
debug?.(
782+
`[processResult] ${colors.cyan(id)} -> ${colors.dim(resolvedId)}`,
783+
)
784+
}
778785
}
779786
return { ...resolved, id: resolvedId, external: true }
780787
}

0 commit comments

Comments
 (0)
Please sign in to comment.