@yarnpkg/nm 3.0.1-rc.1 → 3.0.1-rc.13
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 +17 -5
- package/lib/hoist.d.ts +6 -1
- package/lib/hoist.js +28 -9
- package/package.json +4 -4
|
@@ -73,7 +73,15 @@ const buildLocatorMap = (nodeModulesTree) => {
|
|
|
73
73
|
val.locations = val.locations.sort((loc1, loc2) => {
|
|
74
74
|
const len1 = loc1.split(fslib_1.ppath.delimiter).length;
|
|
75
75
|
const len2 = loc2.split(fslib_1.ppath.delimiter).length;
|
|
76
|
-
|
|
76
|
+
if (loc2 === loc1) {
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
else if (len1 !== len2) {
|
|
80
|
+
return len2 - len1;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return loc2 > loc1 ? 1 : -1;
|
|
84
|
+
}
|
|
77
85
|
});
|
|
78
86
|
}
|
|
79
87
|
return map;
|
|
@@ -194,7 +202,7 @@ const buildPackageTree = (pnp, options) => {
|
|
|
194
202
|
reference: topLocator.reference,
|
|
195
203
|
peerNames: topPkg.packagePeers,
|
|
196
204
|
dependencies: new Set(),
|
|
197
|
-
|
|
205
|
+
dependencyKind: hoist_1.HoisterDependencyKind.WORKSPACE,
|
|
198
206
|
};
|
|
199
207
|
const nodes = new Map();
|
|
200
208
|
const getNodeKey = (name, locator) => `${stringifyLocator(locator)}:${name}`;
|
|
@@ -209,7 +217,11 @@ const buildPackageTree = (pnp, options) => {
|
|
|
209
217
|
}
|
|
210
218
|
const isExternalSoftLinkPackage = isExternalSoftLink(pkg, locator, pnp, topPkgPortableLocation);
|
|
211
219
|
if (!node) {
|
|
212
|
-
|
|
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;
|
|
213
225
|
node = {
|
|
214
226
|
name,
|
|
215
227
|
identName: locator.name,
|
|
@@ -217,8 +229,8 @@ const buildPackageTree = (pnp, options) => {
|
|
|
217
229
|
dependencies: new Set(),
|
|
218
230
|
// View peer dependencies as regular dependencies for workspaces
|
|
219
231
|
// (meeting workspace peer dependency constraints is sometimes hard, sometimes impossible for the nm linker)
|
|
220
|
-
peerNames:
|
|
221
|
-
|
|
232
|
+
peerNames: dependencyKind === hoist_1.HoisterDependencyKind.WORKSPACE ? new Set() : pkg.packagePeers,
|
|
233
|
+
dependencyKind,
|
|
222
234
|
};
|
|
223
235
|
nodes.set(nodeKey, node);
|
|
224
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
|
};
|
|
@@ -801,7 +813,14 @@ const dumpDepTree = (tree) => {
|
|
|
801
813
|
if (nodeCount > MAX_NODES_TO_DUMP || parents.has(pkg))
|
|
802
814
|
return ``;
|
|
803
815
|
nodeCount++;
|
|
804
|
-
const dependencies = Array.from(pkg.dependencies.values()).sort((n1, n2) =>
|
|
816
|
+
const dependencies = Array.from(pkg.dependencies.values()).sort((n1, n2) => {
|
|
817
|
+
if (n1.name === n2.name) {
|
|
818
|
+
return 0;
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
return n1.name > n2.name ? 1 : -1;
|
|
822
|
+
}
|
|
823
|
+
});
|
|
805
824
|
let str = ``;
|
|
806
825
|
parents.add(pkg);
|
|
807
826
|
for (let idx = 0; idx < dependencies.length; idx++) {
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/nm",
|
|
3
|
-
"version": "3.0.1-rc.
|
|
3
|
+
"version": "3.0.1-rc.13",
|
|
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-rc.
|
|
10
|
-
"@yarnpkg/fslib": "^2.6.
|
|
9
|
+
"@yarnpkg/core": "^3.2.0-rc.13",
|
|
10
|
+
"@yarnpkg/fslib": "^2.6.1-rc.8"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@yarnpkg/pnp": "^3.1.1-rc.
|
|
13
|
+
"@yarnpkg/pnp": "^3.1.1-rc.13"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"postpack": "rm -rf lib",
|