@pnpm/installing.deps-resolver 1100.2.2 → 1100.2.4
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/lib/dedupeInjectedDeps.js +16 -9
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/resolveDependencies.d.ts +35 -0
- package/lib/resolveDependencies.js +587 -317
- package/lib/resolveDependencyTree.d.ts +1 -1
- package/lib/resolveDependencyTree.js +9 -29
- package/lib/resolvePeers.js +24 -3
- package/lib/toResolveImporter.js +1 -1
- package/lib/updateProjectManifest.js +16 -1
- package/package.json +29 -29
|
@@ -27,19 +27,26 @@ function getDedupeMap(injectedDepsByProjects, opts) {
|
|
|
27
27
|
for (const [id, deps] of injectedDepsByProjects.entries()) {
|
|
28
28
|
const dedupedInjectedDeps = new Map();
|
|
29
29
|
for (const [alias, dep] of deps.entries()) {
|
|
30
|
-
|
|
31
|
-
// The injected project in the workspace may have dev deps
|
|
32
|
-
const children = Object.entries(opts.depGraph[dep.depPath].children);
|
|
30
|
+
const node = opts.depGraph[dep.depPath];
|
|
33
31
|
const targetProjectDeps = opts.dependenciesByProjectId[dep.id];
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
// injected dep
|
|
32
|
+
// In single-project operations (e.g. `pnpm rm` from inside a workspace package) the target
|
|
33
|
+
// workspace project isn't being resolved, so its children aren't in
|
|
34
|
+
// `dependenciesByProjectId`. The injected dep was resolved against the same workspace
|
|
35
|
+
// package source, so dedupe is safe. The exception is peer-suffixed depPaths, whose
|
|
36
|
+
// resolution depends on the importer's peer context. A plain `link:` would lose that, so
|
|
37
|
+
// we skip dedupe for those. A depPath is `${pkgIdWithPatchHash}${peerDepGraphHash}`, so it
|
|
38
|
+
// carries a peer suffix exactly when it differs from its peer-free `pkgIdWithPatchHash`.
|
|
37
39
|
if (!targetProjectDeps) {
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
+
if (node.pkgIdWithPatchHash === dep.depPath) {
|
|
41
|
+
dedupedInjectedDeps.set(alias, dep.id);
|
|
42
|
+
}
|
|
43
|
+
continue;
|
|
40
44
|
}
|
|
45
|
+
// Check for subgroup not equal.
|
|
46
|
+
// The injected project in the workspace may have dev deps
|
|
47
|
+
const children = Object.entries(node.children);
|
|
41
48
|
const isSubset = children
|
|
42
|
-
.every(([alias, depPath]) => targetProjectDeps
|
|
49
|
+
.every(([alias, depPath]) => targetProjectDeps.get(alias) === depPath);
|
|
43
50
|
if (isSubset) {
|
|
44
51
|
dedupedInjectedDeps.set(alias, dep.id);
|
|
45
52
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { type DependenciesByProjectId, type GenericDependenciesGraphNodeWithReso
|
|
|
9
9
|
export type DependenciesGraph = GenericDependenciesGraphWithResolvedChildren<ResolvedPackage>;
|
|
10
10
|
export type DependenciesGraphNode = GenericDependenciesGraphNodeWithResolvedChildren & ResolvedPackage;
|
|
11
11
|
export { getWantedDependencies, type LinkedDependency, type PinnedVersion, type ResolvedPackage, type UpdateMatchingFunction, type WantedDependency, };
|
|
12
|
+
export { assertValidDependencyAliases, isValidDependencyAlias } from './validateDependencyAlias.js';
|
|
12
13
|
export interface ImporterToResolve extends Importer<{
|
|
13
14
|
isNew?: boolean;
|
|
14
15
|
nodeExecPath?: string;
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { toResolveImporter } from './toResolveImporter.js';
|
|
|
19
19
|
import { updateLockfile } from './updateLockfile.js';
|
|
20
20
|
import { updateProjectManifest } from './updateProjectManifest.js';
|
|
21
21
|
export { getWantedDependencies, };
|
|
22
|
+
export { assertValidDependencyAliases, isValidDependencyAlias } from './validateDependencyAlias.js';
|
|
22
23
|
export async function resolveDependencies(importers, opts) {
|
|
23
24
|
const _toResolveImporter = toResolveImporter.bind(null, {
|
|
24
25
|
defaultUpdateDepth: opts.defaultUpdateDepth,
|
|
@@ -87,7 +87,12 @@ export interface ResolutionContext {
|
|
|
87
87
|
resolvedPkgsById: ResolvedPkgsById;
|
|
88
88
|
resolvePeersFromWorkspaceRoot?: boolean;
|
|
89
89
|
outdatedDependencies: Record<PkgResolutionId, string>;
|
|
90
|
+
packageResolutionBarrier: PackageResolutionBarrier;
|
|
90
91
|
childrenByParentId: ChildrenByParentId;
|
|
92
|
+
childrenResolutionByPkgId: Record<PkgResolutionId, ChildrenResolution>;
|
|
93
|
+
childrenResolutionId: number;
|
|
94
|
+
importerResolutionOrder: Record<string, number>;
|
|
95
|
+
nodeResolutionContextByNodeId: Map<NodeId, NodeResolutionContext>;
|
|
91
96
|
patchedDependencies?: PatchGroupRecord;
|
|
92
97
|
pendingNodes: PendingNode[];
|
|
93
98
|
wantedLockfile: LockfileObject;
|
|
@@ -132,6 +137,26 @@ export interface ResolutionContext {
|
|
|
132
137
|
trustPolicyIgnoreAfter?: number;
|
|
133
138
|
blockExoticSubdeps?: boolean;
|
|
134
139
|
}
|
|
140
|
+
interface PackageResolutionBarrier {
|
|
141
|
+
activeByDepth: Map<number, number>;
|
|
142
|
+
waiters: Array<() => void>;
|
|
143
|
+
}
|
|
144
|
+
interface ChildrenResolutionOwner {
|
|
145
|
+
depth: number;
|
|
146
|
+
importerOrder: number;
|
|
147
|
+
parentPath: PkgResolutionId[];
|
|
148
|
+
}
|
|
149
|
+
interface ChildrenResolution {
|
|
150
|
+
id: number;
|
|
151
|
+
owner: ChildrenResolutionOwner;
|
|
152
|
+
missingPeersOfChildren?: MissingPeersOfChildren;
|
|
153
|
+
}
|
|
154
|
+
interface NodeResolutionContext {
|
|
155
|
+
depth: number;
|
|
156
|
+
installable: boolean;
|
|
157
|
+
parentIds: PkgResolutionId[];
|
|
158
|
+
pkgId: PkgResolutionId;
|
|
159
|
+
}
|
|
135
160
|
export interface MissingPeerInfo {
|
|
136
161
|
range: string;
|
|
137
162
|
optional: boolean;
|
|
@@ -156,6 +181,7 @@ export interface PkgAddress extends PkgAddressOrLinkBase {
|
|
|
156
181
|
rootDir: string;
|
|
157
182
|
missingPeers: MissingPeers;
|
|
158
183
|
missingPeersOfChildren?: MissingPeersOfChildren;
|
|
184
|
+
childrenResolutionId?: number;
|
|
159
185
|
publishedAt?: string;
|
|
160
186
|
saveCatalogName?: string;
|
|
161
187
|
lockedPeerContext?: LockedPeerContext;
|
|
@@ -252,6 +278,15 @@ export declare function resolveDependencies(ctx: ResolutionContext, preferredVer
|
|
|
252
278
|
updateDepth?: number;
|
|
253
279
|
}>, options: ResolvedDependenciesOptions): Promise<ResolvedDependenciesResult>;
|
|
254
280
|
export declare function createNodeIdForLinkedLocalPkg(lockfileDir: string, pkgDir: string): NodeId;
|
|
281
|
+
export declare function buildTree(ctx: {
|
|
282
|
+
childrenByParentId: ChildrenByParentId;
|
|
283
|
+
dependenciesTree: DependenciesTree<ResolvedPackage>;
|
|
284
|
+
resolvedPkgsById: ResolvedPkgsById;
|
|
285
|
+
skipped: Set<PkgResolutionId>;
|
|
286
|
+
}, parentId: PkgResolutionId, parentIds: PkgResolutionId[], children: Array<{
|
|
287
|
+
alias: string;
|
|
288
|
+
id: PkgResolutionId;
|
|
289
|
+
}>, depth: number, installable: boolean): Record<string, NodeId>;
|
|
255
290
|
export interface LockedPeerContext {
|
|
256
291
|
[peerName: string]: DepPath;
|
|
257
292
|
}
|