@pnpm/installing.deps-resolver 1100.2.8 → 1100.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/lib/dedupeInjectedDeps.js +20 -1
- package/lib/depPathCompatibility.d.ts +4 -0
- package/lib/depPathCompatibility.js +28 -0
- package/lib/resolveDependencies.js +3 -1
- package/lib/resolvePeers.js +1 -18
- package/package.json +20 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @pnpm/resolve-dependencies
|
|
2
2
|
|
|
3
|
+
## 1100.2.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed an injected workspace dependency (`injectWorkspacePackages: true`) incorrectly staying as `file:` instead of deduping back to `link:` when an unrelated, ordinary shared dependency resolved to a peer-suffixed variant for the target project's own copy but not for the injected occurrence. See pnpm/pnpm#10433.
|
|
8
|
+
|
|
9
|
+
- Fixed `pnpm update` removing transitive lockfile entries when `dedupePeerDependents` is disabled and the selected package is absent [pnpm/pnpm#12456](https://github.com/pnpm/pnpm/issues/12456).
|
|
10
|
+
|
|
11
|
+
- Updated dependencies:
|
|
12
|
+
- @pnpm/config.version-policy@1100.1.7
|
|
13
|
+
- @pnpm/core-loggers@1100.2.2
|
|
14
|
+
- @pnpm/deps.graph-hasher@1100.2.10
|
|
15
|
+
- @pnpm/deps.path@1100.0.9
|
|
16
|
+
- @pnpm/fetching.pick-fetcher@1100.1.1
|
|
17
|
+
- @pnpm/fs.symlink-dependency@1100.0.11
|
|
18
|
+
- @pnpm/hooks.types@1100.2.1
|
|
19
|
+
- @pnpm/lockfile.preferred-versions@1100.0.20
|
|
20
|
+
- @pnpm/lockfile.pruner@1100.0.14
|
|
21
|
+
- @pnpm/lockfile.types@1100.0.14
|
|
22
|
+
- @pnpm/lockfile.utils@1100.1.3
|
|
23
|
+
- @pnpm/patching.config@1100.0.10
|
|
24
|
+
- @pnpm/pkg-manifest.reader@1100.0.10
|
|
25
|
+
- @pnpm/pkg-manifest.utils@1100.2.7
|
|
26
|
+
- @pnpm/resolving.npm-resolver@1102.1.3
|
|
27
|
+
- @pnpm/resolving.resolver-base@1100.5.2
|
|
28
|
+
- @pnpm/store.controller-types@1100.1.8
|
|
29
|
+
- @pnpm/types@1101.4.0
|
|
30
|
+
|
|
3
31
|
## 1100.2.8
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import normalize from 'normalize-path';
|
|
3
|
+
import { isCompatibleAndHasMoreDeps } from './depPathCompatibility.js';
|
|
3
4
|
export function dedupeInjectedDeps(opts) {
|
|
4
5
|
const injectedDepsByProjects = getInjectedDepsByProjects(opts);
|
|
5
6
|
const dedupeMap = getDedupeMap(injectedDepsByProjects, opts);
|
|
@@ -46,7 +47,25 @@ function getDedupeMap(injectedDepsByProjects, opts) {
|
|
|
46
47
|
// The injected project in the workspace may have dev deps
|
|
47
48
|
const children = Object.entries(node.children);
|
|
48
49
|
const isSubset = children
|
|
49
|
-
.every(([alias, depPath]) =>
|
|
50
|
+
.every(([alias, depPath]) => {
|
|
51
|
+
const targetDepPath = targetProjectDeps.get(alias);
|
|
52
|
+
if (targetDepPath === depPath)
|
|
53
|
+
return true;
|
|
54
|
+
if (targetDepPath == null)
|
|
55
|
+
return false;
|
|
56
|
+
// A shared dep can resolve peer-suffixed on one side and peer-free on
|
|
57
|
+
// the other (e.g. an existing lockfile pinned debug's optional
|
|
58
|
+
// supports-color for the target project but not the injected
|
|
59
|
+
// occurrence). Accept the target's variant when it's the same package
|
|
60
|
+
// identity and a compatible superset. See pnpm/pnpm#10433.
|
|
61
|
+
const targetNode = opts.depGraph[targetDepPath];
|
|
62
|
+
const injectedChildNode = opts.depGraph[depPath];
|
|
63
|
+
if (targetNode == null || injectedChildNode == null)
|
|
64
|
+
return false;
|
|
65
|
+
if (targetNode.pkgIdWithPatchHash !== injectedChildNode.pkgIdWithPatchHash)
|
|
66
|
+
return false;
|
|
67
|
+
return isCompatibleAndHasMoreDeps(opts.depGraph, targetDepPath, depPath);
|
|
68
|
+
});
|
|
50
69
|
if (isSubset) {
|
|
51
70
|
dedupedInjectedDeps.set(alias, dep.id);
|
|
52
71
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DepPath } from '@pnpm/types';
|
|
2
|
+
import type { GenericDependenciesGraphNodeWithResolvedChildren, GenericDependenciesGraphWithResolvedChildren, PartialResolvedPackage } from './resolvePeers.js';
|
|
3
|
+
export declare function nodeDepsCount(node: GenericDependenciesGraphNodeWithResolvedChildren): number;
|
|
4
|
+
export declare function isCompatibleAndHasMoreDeps<T extends PartialResolvedPackage>(depGraph: GenericDependenciesGraphWithResolvedChildren<T>, depPath1: DepPath, depPath2: DepPath): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Shared helpers used by both resolvePeers (dedupePeerDependents) and
|
|
2
|
+
// dedupeInjectedDeps. Lives in its own module so neither consumer has to import
|
|
3
|
+
// the other, which would create a runtime cycle. The type imports above are
|
|
4
|
+
// erased at build time, so no cycle exists at runtime.
|
|
5
|
+
export function nodeDepsCount(node) {
|
|
6
|
+
return Object.keys(node.children).length + node.resolvedPeerNames.size;
|
|
7
|
+
}
|
|
8
|
+
// Whether `depPath1` is a superset-or-equal of `depPath2`: same-or-more resolved
|
|
9
|
+
// children and peers. Compares dependency/peer *sets* only, not package
|
|
10
|
+
// identity, so callers must pass depPaths already known to share a
|
|
11
|
+
// `pkgIdWithPatchHash` — otherwise two unrelated leaf packages (both with empty
|
|
12
|
+
// sets) would count as compatible.
|
|
13
|
+
export function isCompatibleAndHasMoreDeps(depGraph, depPath1, depPath2) {
|
|
14
|
+
const node1 = depGraph[depPath1];
|
|
15
|
+
const node2 = depGraph[depPath2];
|
|
16
|
+
if (nodeDepsCount(node1) < nodeDepsCount(node2))
|
|
17
|
+
return false;
|
|
18
|
+
const node1DepPathsSet = new Set(Object.values(node1.children));
|
|
19
|
+
const node2DepPaths = Object.values(node2.children);
|
|
20
|
+
if (!node2DepPaths.every((depPath) => node1DepPathsSet.has(depPath)))
|
|
21
|
+
return false;
|
|
22
|
+
for (const depPath of node2.resolvedPeerNames) {
|
|
23
|
+
if (!node1.resolvedPeerNames.has(depPath))
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=depPathCompatibility.js.map
|
|
@@ -1106,7 +1106,9 @@ async function resolveDependency(wantedDependency, ctx, options) {
|
|
|
1106
1106
|
currentPkg.dependencyLockfile &&
|
|
1107
1107
|
currentPkg.name &&
|
|
1108
1108
|
await pathExists(path.join(ctx.virtualStoreDir, dp.depPathToFilename(currentPkg.depPath, ctx.virtualStoreDirMaxLength), 'node_modules', currentPkg.name, 'package.json')));
|
|
1109
|
-
if (!options.update && !options.proceed &&
|
|
1109
|
+
if (!options.update && !options.proceed &&
|
|
1110
|
+
options.currentDepth === Math.max(0, options.updateDepth) &&
|
|
1111
|
+
(currentPkg.resolution != null) && depIsLinked) {
|
|
1110
1112
|
return null;
|
|
1111
1113
|
}
|
|
1112
1114
|
let pkgResponse;
|
package/lib/resolvePeers.js
CHANGED
|
@@ -7,6 +7,7 @@ import pDefer, {} from 'p-defer';
|
|
|
7
7
|
import { partition, pick } from 'ramda';
|
|
8
8
|
import semver from 'semver';
|
|
9
9
|
import { dedupeInjectedDeps } from './dedupeInjectedDeps.js';
|
|
10
|
+
import { isCompatibleAndHasMoreDeps, nodeDepsCount } from './depPathCompatibility.js';
|
|
10
11
|
import { linkPathToPeerVersion } from './linkPathToPeerVersion.js';
|
|
11
12
|
import { mergePeers } from './mergePeers.js';
|
|
12
13
|
export async function resolvePeers(opts) {
|
|
@@ -241,9 +242,6 @@ function breakDepPathAwaitCycles(opts) {
|
|
|
241
242
|
opts.pathsByNodeIdPromises.get(nodeId)?.resolve(`${name}@${version}`);
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
|
-
function nodeDepsCount(node) {
|
|
245
|
-
return Object.keys(node.children).length + node.resolvedPeerNames.size;
|
|
246
|
-
}
|
|
247
245
|
function deduplicateAll(depGraph, duplicates) {
|
|
248
246
|
const { depPathsMap, remainingDuplicates } = deduplicateDepPaths(duplicates, depGraph);
|
|
249
247
|
if (remainingDuplicates.length === duplicates.length) {
|
|
@@ -307,21 +305,6 @@ function deduplicateDepPaths(duplicates, depGraph) {
|
|
|
307
305
|
remainingDuplicates,
|
|
308
306
|
};
|
|
309
307
|
}
|
|
310
|
-
function isCompatibleAndHasMoreDeps(depGraph, depPath1, depPath2) {
|
|
311
|
-
const node1 = depGraph[depPath1];
|
|
312
|
-
const node2 = depGraph[depPath2];
|
|
313
|
-
if (nodeDepsCount(node1) < nodeDepsCount(node2))
|
|
314
|
-
return false;
|
|
315
|
-
const node1DepPathsSet = new Set(Object.values(node1.children));
|
|
316
|
-
const node2DepPaths = Object.values(node2.children);
|
|
317
|
-
if (!node2DepPaths.every((depPath) => node1DepPathsSet.has(depPath)))
|
|
318
|
-
return false;
|
|
319
|
-
for (const depPath of node2.resolvedPeerNames) {
|
|
320
|
-
if (!node1.resolvedPeerNames.has(depPath))
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
return true;
|
|
324
|
-
}
|
|
325
308
|
function createPkgsByName(dependenciesTree, { directNodeIdsByAlias, topParents }) {
|
|
326
309
|
const parentRefs = toPkgByName(Array.from(directNodeIdsByAlias.entries())
|
|
327
310
|
.map(([alias, nodeId]) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/installing.deps-resolver",
|
|
3
|
-
"version": "1100.2.
|
|
3
|
+
"version": "1100.2.9",
|
|
4
4
|
"description": "Resolves dependency graph of a package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -29,28 +29,28 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@pnpm/catalogs.resolver": "1100.0.0",
|
|
31
31
|
"@pnpm/catalogs.types": "1100.0.0",
|
|
32
|
-
"@pnpm/config.version-policy": "1100.1.
|
|
32
|
+
"@pnpm/config.version-policy": "1100.1.7",
|
|
33
33
|
"@pnpm/constants": "1100.0.0",
|
|
34
|
-
"@pnpm/core-loggers": "1100.2.
|
|
35
|
-
"@pnpm/deps.graph-hasher": "1100.2.
|
|
36
|
-
"@pnpm/deps.path": "1100.0.
|
|
34
|
+
"@pnpm/core-loggers": "1100.2.2",
|
|
35
|
+
"@pnpm/deps.graph-hasher": "1100.2.10",
|
|
36
|
+
"@pnpm/deps.path": "1100.0.9",
|
|
37
37
|
"@pnpm/deps.peer-range": "1100.0.2",
|
|
38
38
|
"@pnpm/error": "1100.0.1",
|
|
39
|
-
"@pnpm/fetching.pick-fetcher": "1100.1.
|
|
40
|
-
"@pnpm/fs.symlink-dependency": "1100.0.
|
|
41
|
-
"@pnpm/hooks.types": "1100.2.
|
|
42
|
-
"@pnpm/lockfile.preferred-versions": "1100.0.
|
|
43
|
-
"@pnpm/lockfile.pruner": "1100.0.
|
|
44
|
-
"@pnpm/lockfile.types": "1100.0.
|
|
45
|
-
"@pnpm/lockfile.utils": "1100.1.
|
|
46
|
-
"@pnpm/patching.config": "1100.0.
|
|
39
|
+
"@pnpm/fetching.pick-fetcher": "1100.1.1",
|
|
40
|
+
"@pnpm/fs.symlink-dependency": "1100.0.11",
|
|
41
|
+
"@pnpm/hooks.types": "1100.2.1",
|
|
42
|
+
"@pnpm/lockfile.preferred-versions": "1100.0.20",
|
|
43
|
+
"@pnpm/lockfile.pruner": "1100.0.14",
|
|
44
|
+
"@pnpm/lockfile.types": "1100.0.14",
|
|
45
|
+
"@pnpm/lockfile.utils": "1100.1.3",
|
|
46
|
+
"@pnpm/patching.config": "1100.0.10",
|
|
47
47
|
"@pnpm/patching.types": "1100.0.0",
|
|
48
|
-
"@pnpm/pkg-manifest.reader": "1100.0.
|
|
49
|
-
"@pnpm/pkg-manifest.utils": "1100.2.
|
|
50
|
-
"@pnpm/resolving.npm-resolver": "1102.1.
|
|
51
|
-
"@pnpm/resolving.resolver-base": "1100.5.
|
|
52
|
-
"@pnpm/store.controller-types": "1100.1.
|
|
53
|
-
"@pnpm/types": "1101.
|
|
48
|
+
"@pnpm/pkg-manifest.reader": "1100.0.10",
|
|
49
|
+
"@pnpm/pkg-manifest.utils": "1100.2.7",
|
|
50
|
+
"@pnpm/resolving.npm-resolver": "1102.1.3",
|
|
51
|
+
"@pnpm/resolving.resolver-base": "1100.5.2",
|
|
52
|
+
"@pnpm/store.controller-types": "1100.1.8",
|
|
53
|
+
"@pnpm/types": "1101.4.0",
|
|
54
54
|
"@pnpm/util.lex-comparator": "^4.0.1",
|
|
55
55
|
"@pnpm/workspace.spec-parser": "1100.0.0",
|
|
56
56
|
"@yarnpkg/core": "4.8.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@jest/globals": "30.4.1",
|
|
77
|
-
"@pnpm/installing.deps-resolver": "1100.2.
|
|
77
|
+
"@pnpm/installing.deps-resolver": "1100.2.9",
|
|
78
78
|
"@pnpm/logger": "1100.0.0",
|
|
79
79
|
"@types/normalize-path": "^3.0.2",
|
|
80
80
|
"@types/ramda": "0.31.1",
|