From 5cfe9e77a526db8fbe3da548b12d1b502aeecaaa Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 26 Jan 2023 02:32:38 +0200 Subject: [PATCH] fix: lockfile v6 on projects with patched deps (#5979) close #5967 --- .changeset/neat-suns-smoke.md | 6 ++++++ pkg-manager/resolve-dependencies/src/resolveDependencies.ts | 3 ++- .../resolve-dependencies/src/resolveDependencyTree.ts | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/neat-suns-smoke.md diff --git a/.changeset/neat-suns-smoke.md b/.changeset/neat-suns-smoke.md new file mode 100644 index 0000000000..2e731fd422 --- /dev/null +++ b/.changeset/neat-suns-smoke.md @@ -0,0 +1,6 @@ +--- +"@pnpm/resolve-dependencies": patch +"pnpm": patch +--- + +Fix lockfile v6 on projects that use patched dependencies [#5967](https://github.com/pnpm/pnpm/issues/5967). diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts index a220950e6f..87f6e18c77 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts @@ -159,6 +159,7 @@ export interface ResolutionContext { resolutionMode?: 'highest' | 'time-based' virtualStoreDir: string updateMatching?: (pkgName: string) => boolean + useLockfileV6?: boolean workspacePackages?: WorkspacePackages missingPeersOfChildrenByPkgId: Record } @@ -1158,7 +1159,7 @@ async function resolveDependency ( const patchFile = ctx.patchedDependencies?.[nameAndVersion] if (patchFile) { ctx.appliedPatches.add(nameAndVersion) - depPath += `_${patchFile.hash}` + depPath += ctx.useLockfileV6 ? `(patch_hash=${patchFile.hash})` : `_${patchFile.hash}` } // We are building the dependency tree only until there are new packages diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts index e67311651c..4b8725702f 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts @@ -129,6 +129,7 @@ export async function resolveDependencyTree ( updatedSet: new Set(), workspacePackages: opts.workspacePackages, missingPeersOfChildrenByPkgId: {}, + useLockfileV6: opts.useLockfileV6, } const resolveArgs: ImporterToResolve[] = importers.map((importer) => {