@yarnpkg/nm 3.0.1-rc.6 → 3.0.1
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/buildNodeModulesTree.js +8 -4
- package/lib/hoist.d.ts +6 -1
- package/lib/hoist.js +20 -8
- package/package.json +5 -6
|
@@ -202,7 +202,7 @@ const buildPackageTree = (pnp, options) => {
|
|
|
202
202
|
reference: topLocator.reference,
|
|
203
203
|
peerNames: topPkg.packagePeers,
|
|
204
204
|
dependencies: new Set(),
|
|
205
|
-
|
|
205
|
+
dependencyKind: hoist_1.HoisterDependencyKind.WORKSPACE,
|
|
206
206
|
};
|
|
207
207
|
const nodes = new Map();
|
|
208
208
|
const getNodeKey = (name, locator) => `${stringifyLocator(locator)}:${name}`;
|
|
@@ -217,7 +217,11 @@ const buildPackageTree = (pnp, options) => {
|
|
|
217
217
|
}
|
|
218
218
|
const isExternalSoftLinkPackage = isExternalSoftLink(pkg, locator, pnp, topPkgPortableLocation);
|
|
219
219
|
if (!node) {
|
|
220
|
-
|
|
220
|
+
let dependencyKind = hoist_1.HoisterDependencyKind.REGULAR;
|
|
221
|
+
if (isExternalSoftLinkPackage)
|
|
222
|
+
dependencyKind = hoist_1.HoisterDependencyKind.EXTERNAL_SOFT_LINK;
|
|
223
|
+
else if (pkg.linkType === LinkType.SOFT && locator.name.endsWith(WORKSPACE_NAME_SUFFIX))
|
|
224
|
+
dependencyKind = hoist_1.HoisterDependencyKind.WORKSPACE;
|
|
221
225
|
node = {
|
|
222
226
|
name,
|
|
223
227
|
identName: locator.name,
|
|
@@ -225,8 +229,8 @@ const buildPackageTree = (pnp, options) => {
|
|
|
225
229
|
dependencies: new Set(),
|
|
226
230
|
// View peer dependencies as regular dependencies for workspaces
|
|
227
231
|
// (meeting workspace peer dependency constraints is sometimes hard, sometimes impossible for the nm linker)
|
|
228
|
-
peerNames:
|
|
229
|
-
|
|
232
|
+
peerNames: dependencyKind === hoist_1.HoisterDependencyKind.WORKSPACE ? new Set() : pkg.packagePeers,
|
|
233
|
+
dependencyKind,
|
|
230
234
|
};
|
|
231
235
|
nodes.set(nodeKey, node);
|
|
232
236
|
}
|
package/lib/hoist.d.ts
CHANGED
|
@@ -46,6 +46,11 @@
|
|
|
46
46
|
* until you run out of candidates for current tree root.
|
|
47
47
|
*/
|
|
48
48
|
declare type PackageName = string;
|
|
49
|
+
export declare enum HoisterDependencyKind {
|
|
50
|
+
REGULAR = 0,
|
|
51
|
+
WORKSPACE = 1,
|
|
52
|
+
EXTERNAL_SOFT_LINK = 2
|
|
53
|
+
}
|
|
49
54
|
export declare type HoisterTree = {
|
|
50
55
|
name: PackageName;
|
|
51
56
|
identName: PackageName;
|
|
@@ -53,7 +58,7 @@ export declare type HoisterTree = {
|
|
|
53
58
|
dependencies: Set<HoisterTree>;
|
|
54
59
|
peerNames: Set<PackageName>;
|
|
55
60
|
hoistPriority?: number;
|
|
56
|
-
|
|
61
|
+
dependencyKind?: HoisterDependencyKind;
|
|
57
62
|
};
|
|
58
63
|
export declare type HoisterResult = {
|
|
59
64
|
name: PackageName;
|
package/lib/hoist.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hoist = void 0;
|
|
3
|
+
exports.hoist = exports.HoisterDependencyKind = void 0;
|
|
4
|
+
var HoisterDependencyKind;
|
|
5
|
+
(function (HoisterDependencyKind) {
|
|
6
|
+
HoisterDependencyKind[HoisterDependencyKind["REGULAR"] = 0] = "REGULAR";
|
|
7
|
+
HoisterDependencyKind[HoisterDependencyKind["WORKSPACE"] = 1] = "WORKSPACE";
|
|
8
|
+
HoisterDependencyKind[HoisterDependencyKind["EXTERNAL_SOFT_LINK"] = 2] = "EXTERNAL_SOFT_LINK";
|
|
9
|
+
})(HoisterDependencyKind = exports.HoisterDependencyKind || (exports.HoisterDependencyKind = {}));
|
|
4
10
|
var Hoistable;
|
|
5
11
|
(function (Hoistable) {
|
|
6
12
|
Hoistable[Hoistable["YES"] = 0] = "YES";
|
|
@@ -134,7 +140,7 @@ const getUsedDependencies = (rootNodePath) => {
|
|
|
134
140
|
const decoupleGraphNode = (parent, node) => {
|
|
135
141
|
if (node.decoupled)
|
|
136
142
|
return node;
|
|
137
|
-
const { name, references, ident, locator, dependencies, originalDependencies, hoistedDependencies, peerNames, reasons, isHoistBorder, hoistPriority,
|
|
143
|
+
const { name, references, ident, locator, dependencies, originalDependencies, hoistedDependencies, peerNames, reasons, isHoistBorder, hoistPriority, dependencyKind, hoistedFrom, hoistedTo } = node;
|
|
138
144
|
// To perform node hoisting from parent node we must clone parent nodes up to the root node,
|
|
139
145
|
// because some other package in the tree might depend on the parent package where hoisting
|
|
140
146
|
// cannot be performed
|
|
@@ -151,7 +157,7 @@ const decoupleGraphNode = (parent, node) => {
|
|
|
151
157
|
decoupled: true,
|
|
152
158
|
isHoistBorder,
|
|
153
159
|
hoistPriority,
|
|
154
|
-
|
|
160
|
+
dependencyKind,
|
|
155
161
|
hoistedFrom: new Map(hoistedFrom),
|
|
156
162
|
hoistedTo: new Map(hoistedTo),
|
|
157
163
|
};
|
|
@@ -323,11 +329,17 @@ const getNodeHoistInfo = (rootNode, rootNodePathLocators, nodePath, node, usedDe
|
|
|
323
329
|
if (outputReason && !isHoistable)
|
|
324
330
|
reason = `- self-reference`;
|
|
325
331
|
if (isHoistable) {
|
|
326
|
-
isHoistable =
|
|
332
|
+
isHoistable = node.dependencyKind !== HoisterDependencyKind.WORKSPACE;
|
|
327
333
|
if (outputReason && !isHoistable) {
|
|
328
334
|
reason = `- workspace`;
|
|
329
335
|
}
|
|
330
336
|
}
|
|
337
|
+
if (isHoistable) {
|
|
338
|
+
isHoistable = node.dependencyKind !== HoisterDependencyKind.EXTERNAL_SOFT_LINK || node.dependencies.size === 0;
|
|
339
|
+
if (outputReason && !isHoistable) {
|
|
340
|
+
reason = `- external soft link with unhoisted dependencies`;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
331
343
|
if (isHoistable) {
|
|
332
344
|
// Direct workspace dependencies must be hoisted to any common ancestor workspace of all the
|
|
333
345
|
// graph paths that include the dependency, because otherwise running app with
|
|
@@ -340,7 +352,7 @@ const getNodeHoistInfo = (rootNode, rootNodePathLocators, nodePath, node, usedDe
|
|
|
340
352
|
// It is difficult to find all common ancestors, but there is one easy to find common ancestor -
|
|
341
353
|
// the root workspace, so, for now, we either hoist direct dependencies into the root workspace, or we keep them
|
|
342
354
|
// unhoisted, thus we are safe from various pathological cases with `--preserve-symlinks`
|
|
343
|
-
isHoistable =
|
|
355
|
+
isHoistable = parentNode.dependencyKind !== HoisterDependencyKind.WORKSPACE || parentNode.hoistedFrom.has(node.name) || rootNodePathLocators.size === 1;
|
|
344
356
|
if (outputReason && !isHoistable) {
|
|
345
357
|
reason = parentNode.reasons.get(node.name);
|
|
346
358
|
}
|
|
@@ -614,7 +626,7 @@ const cloneTree = (tree, options) => {
|
|
|
614
626
|
decoupled: true,
|
|
615
627
|
isHoistBorder: true,
|
|
616
628
|
hoistPriority: 0,
|
|
617
|
-
|
|
629
|
+
dependencyKind: HoisterDependencyKind.WORKSPACE,
|
|
618
630
|
hoistedFrom: new Map(),
|
|
619
631
|
hoistedTo: new Map(),
|
|
620
632
|
};
|
|
@@ -623,7 +635,7 @@ const cloneTree = (tree, options) => {
|
|
|
623
635
|
let workNode = seenNodes.get(node);
|
|
624
636
|
const isSeen = !!workNode;
|
|
625
637
|
if (!workNode) {
|
|
626
|
-
const { name, identName, reference, peerNames, hoistPriority,
|
|
638
|
+
const { name, identName, reference, peerNames, hoistPriority, dependencyKind } = node;
|
|
627
639
|
const dependenciesNmHoistingLimits = options.hoistingLimits.get(parentNode.locator);
|
|
628
640
|
workNode = {
|
|
629
641
|
name,
|
|
@@ -638,7 +650,7 @@ const cloneTree = (tree, options) => {
|
|
|
638
650
|
decoupled: true,
|
|
639
651
|
isHoistBorder: dependenciesNmHoistingLimits ? dependenciesNmHoistingLimits.has(name) : false,
|
|
640
652
|
hoistPriority: hoistPriority || 0,
|
|
641
|
-
|
|
653
|
+
dependencyKind: dependencyKind || HoisterDependencyKind.REGULAR,
|
|
642
654
|
hoistedFrom: new Map(),
|
|
643
655
|
hoistedTo: new Map(),
|
|
644
656
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/nm",
|
|
3
|
-
"version": "3.0.1
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@yarnpkg/core": "^3.2.0
|
|
10
|
-
"@yarnpkg/fslib": "^2.6.1
|
|
9
|
+
"@yarnpkg/core": "^3.2.0",
|
|
10
|
+
"@yarnpkg/fslib": "^2.6.1"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@yarnpkg/pnp": "^3.
|
|
13
|
+
"@yarnpkg/pnp": "^3.2.0"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"postpack": "rm -rf lib",
|
|
@@ -32,6 +32,5 @@
|
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
|
|
35
|
-
}
|
|
36
|
-
"stableVersion": "3.0.0"
|
|
35
|
+
}
|
|
37
36
|
}
|