fix: resolution of aliased dependencies (#7967)

close #7957
This commit is contained in:
Zoltan Kochan authored and GitHub committed 2024-04-19 02:46:05 +02:00
1 parent 65df252783
commit eb1947576f
2 files changed
+11 -1

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
---
"@pnpm/resolve-dependencies": patch
"pnpm": patch
---
Fix aliased dependencies resolution on repeat install with existing lockfile [#7957](https://github.com/pnpm/pnpm/issues/7957).
@@ -1139,7 +1139,11 @@ async function resolveDependency (
}
try {
if (!options.update && currentPkg.version && currentPkg.pkgId?.endsWith(`@${currentPkg.version}`)) {
wantedDependency.pref = currentPkg.version
if (semver.validRange(wantedDependency.pref)) {
wantedDependency.pref = currentPkg.version
} else if (wantedDependency.pref.startsWith('npm:')) {
wantedDependency.pref = `${wantedDependency.pref.substring(0, wantedDependency.pref.lastIndexOf('@') + 1)}${currentPkg.version}`
}
}
pkgResponse = await ctx.storeController.requestPackage(wantedDependency, {
alwaysTryWorkspacePackages: ctx.linkWorkspacePackagesDepth >= options.currentDepth,