fix: resolution of aliased dependencies (#7967)

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

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).

View File

@@ -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,