fix: check for peerDependenciesMeta in pkgIsLeaf to fix non-determinism (#6112)

close #5106
This commit is contained in:
Brandon Cheng
2023-02-19 21:15:36 -05:00
committed by GitHub
parent 0377d93678
commit 1b2e09ccfd
2 changed files with 10 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/resolve-dependencies": patch
pnpm: patch
---
Fix a case of installs not being deterministic and causing lockfile changes between repeat installs. When a dependency only declares `peerDependenciesMeta` and not `peerDependencies`, `dependencies`, or `optionalDependencies`, the dependency's peers were not considered deterministically before.

View File

@@ -1377,7 +1377,10 @@ function getMissingPeers (pkg: PackageManifest) {
function pkgIsLeaf (pkg: PackageManifest) {
return isEmpty(pkg.dependencies ?? {}) &&
isEmpty(pkg.optionalDependencies ?? {}) &&
isEmpty(pkg.peerDependencies ?? {})
isEmpty(pkg.peerDependencies ?? {}) &&
// Package manifests can declare peerDependenciesMeta without declaring
// peerDependencies. peerDependenciesMeta implies the later.
isEmpty(pkg.peerDependenciesMeta ?? {})
}
function getResolvedPackage (