@yarnpkg/nm 4.0.0-rc.9 → 4.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.d.ts +6 -6
- package/lib/buildNodeModulesTree.js +11 -10
- package/lib/hoist.d.ts +5 -5
- package/lib/hoist.js +2 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -1
- package/package.json +14 -11
|
@@ -10,10 +10,10 @@ export declare enum NodeModulesHoistingLimits {
|
|
|
10
10
|
DEPENDENCIES = "dependencies",
|
|
11
11
|
NONE = "none"
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type NodeModulesBaseNode = {
|
|
14
14
|
dirList: Set<Filename>;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type NodeModulesPackageNode = {
|
|
17
17
|
locator: LocatorKey;
|
|
18
18
|
target: PortablePath;
|
|
19
19
|
linkType: LinkType;
|
|
@@ -30,8 +30,8 @@ export declare type NodeModulesPackageNode = {
|
|
|
30
30
|
* /home/user/project/node_modules/foo -> {target: '/home/user/project/.yarn/.cache/foo.zip/node_modules/foo', linkType: 'HARD'}
|
|
31
31
|
* /home/user/project/node_modules/bar -> {target: '/home/user/project/packages/bar', linkType: 'SOFT'}
|
|
32
32
|
*/
|
|
33
|
-
export
|
|
34
|
-
export
|
|
33
|
+
export type NodeModulesTree = Map<PortablePath, NodeModulesBaseNode | NodeModulesPackageNode>;
|
|
34
|
+
export type NodeModulesTreeErrors = Array<{
|
|
35
35
|
messageName: MessageName;
|
|
36
36
|
text: string;
|
|
37
37
|
}>;
|
|
@@ -43,7 +43,7 @@ export interface NodeModulesTreeOptions {
|
|
|
43
43
|
project?: Project;
|
|
44
44
|
}
|
|
45
45
|
/** Package locator key for usage inside maps */
|
|
46
|
-
|
|
46
|
+
type LocatorKey = string;
|
|
47
47
|
/**
|
|
48
48
|
* Returns path to archive, if package location is inside the archive.
|
|
49
49
|
*
|
|
@@ -65,7 +65,7 @@ export declare const buildNodeModulesTree: (pnp: PnpApi, options: NodeModulesTre
|
|
|
65
65
|
errors: NodeModulesTreeErrors;
|
|
66
66
|
preserveSymlinksRequired: boolean;
|
|
67
67
|
};
|
|
68
|
-
export
|
|
68
|
+
export type NodeModulesLocatorMap = Map<LocatorKey, {
|
|
69
69
|
target: PortablePath;
|
|
70
70
|
linkType: LinkType;
|
|
71
71
|
locations: Array<PortablePath>;
|
|
@@ -12,13 +12,13 @@ var LinkType;
|
|
|
12
12
|
(function (LinkType) {
|
|
13
13
|
LinkType["HARD"] = "HARD";
|
|
14
14
|
LinkType["SOFT"] = "SOFT";
|
|
15
|
-
})(LinkType
|
|
15
|
+
})(LinkType || (exports.LinkType = LinkType = {}));
|
|
16
16
|
var NodeModulesHoistingLimits;
|
|
17
17
|
(function (NodeModulesHoistingLimits) {
|
|
18
18
|
NodeModulesHoistingLimits["WORKSPACES"] = "workspaces";
|
|
19
19
|
NodeModulesHoistingLimits["DEPENDENCIES"] = "dependencies";
|
|
20
20
|
NodeModulesHoistingLimits["NONE"] = "none";
|
|
21
|
-
})(NodeModulesHoistingLimits
|
|
21
|
+
})(NodeModulesHoistingLimits || (exports.NodeModulesHoistingLimits = NodeModulesHoistingLimits = {}));
|
|
22
22
|
/** node_modules path segment */
|
|
23
23
|
const NODE_MODULES = `node_modules`;
|
|
24
24
|
/**
|
|
@@ -207,7 +207,6 @@ const buildPackageTree = (pnp, options) => {
|
|
|
207
207
|
const nodes = new Map();
|
|
208
208
|
const getNodeKey = (name, locator) => `${stringifyLocator(locator)}:${name}`;
|
|
209
209
|
const addPackageToTree = (name, pkg, locator, parent, parentPkg, parentDependencies, parentRelativeCwd, isHoistBorder) => {
|
|
210
|
-
var _a, _b;
|
|
211
210
|
const nodeKey = getNodeKey(name, locator);
|
|
212
211
|
let node = nodes.get(nodeKey);
|
|
213
212
|
const isSeen = !!node;
|
|
@@ -331,9 +330,9 @@ const buildPackageTree = (pnp, options) => {
|
|
|
331
330
|
}
|
|
332
331
|
}
|
|
333
332
|
}
|
|
334
|
-
const parentHoistingLimits =
|
|
333
|
+
const parentHoistingLimits = options.hoistingLimitsByCwd?.get(parentRelativeCwd);
|
|
335
334
|
const relativeDepCwd = isExternalSoftLinkDep ? parentRelativeCwd : fslib_1.ppath.relative(topPkgPortableLocation, fslib_1.npath.toPortablePath(depPkg.packageLocation)) || fslib_2.PortablePath.dot;
|
|
336
|
-
const depHoistingLimits =
|
|
335
|
+
const depHoistingLimits = options.hoistingLimitsByCwd?.get(relativeDepCwd);
|
|
337
336
|
const isHoistBorder = parentHoistingLimits === NodeModulesHoistingLimits.DEPENDENCIES
|
|
338
337
|
|| depHoistingLimits === NodeModulesHoistingLimits.DEPENDENCIES
|
|
339
338
|
|| depHoistingLimits === NodeModulesHoistingLimits.WORKSPACES;
|
|
@@ -390,11 +389,11 @@ const populateNodeModulesTree = (pnp, hoistedTree, options) => {
|
|
|
390
389
|
const getPackageName = (identName) => {
|
|
391
390
|
const [nameOrScope, name] = identName.split(`/`);
|
|
392
391
|
return name ? {
|
|
393
|
-
scope:
|
|
394
|
-
name:
|
|
392
|
+
scope: nameOrScope,
|
|
393
|
+
name: name,
|
|
395
394
|
} : {
|
|
396
395
|
scope: null,
|
|
397
|
-
name:
|
|
396
|
+
name: nameOrScope,
|
|
398
397
|
};
|
|
399
398
|
};
|
|
400
399
|
const seenNodes = new Set();
|
|
@@ -402,9 +401,11 @@ const populateNodeModulesTree = (pnp, hoistedTree, options) => {
|
|
|
402
401
|
if (seenNodes.has(pkg))
|
|
403
402
|
return;
|
|
404
403
|
seenNodes.add(pkg);
|
|
404
|
+
const pkgReferences = Array.from(pkg.references).sort().join(`#`);
|
|
405
405
|
for (const dep of pkg.dependencies) {
|
|
406
|
+
const depReferences = Array.from(dep.references).sort().join(`#`);
|
|
406
407
|
// We do not want self-references in node_modules, since they confuse existing tools
|
|
407
|
-
if (dep === pkg)
|
|
408
|
+
if (dep.identName === pkg.identName.replace(WORKSPACE_NAME_SUFFIX, ``) && depReferences === pkgReferences)
|
|
408
409
|
continue;
|
|
409
410
|
const references = Array.from(dep.references).sort();
|
|
410
411
|
const locator = { name: dep.identName, reference: references[0] };
|
|
@@ -443,7 +444,7 @@ const populateNodeModulesTree = (pnp, hoistedTree, options) => {
|
|
|
443
444
|
const nodeModulesIdx = segments.indexOf(NODE_MODULES);
|
|
444
445
|
for (let segCount = segments.length - 1; nodeModulesIdx >= 0 && segCount > nodeModulesIdx; segCount--) {
|
|
445
446
|
const dirPath = fslib_1.npath.toPortablePath(segments.slice(0, segCount).join(fslib_1.ppath.sep));
|
|
446
|
-
const targetDir =
|
|
447
|
+
const targetDir = segments[segCount];
|
|
447
448
|
const subdirs = tree.get(dirPath);
|
|
448
449
|
if (!subdirs) {
|
|
449
450
|
tree.set(dirPath, { dirList: new Set([targetDir]) });
|
package/lib/hoist.d.ts
CHANGED
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
* the next node as current tree root and run the algorithm again
|
|
46
46
|
* until you run out of candidates for current tree root.
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
type PackageName = string;
|
|
49
49
|
export declare enum HoisterDependencyKind {
|
|
50
50
|
REGULAR = 0,
|
|
51
51
|
WORKSPACE = 1,
|
|
52
52
|
EXTERNAL_SOFT_LINK = 2
|
|
53
53
|
}
|
|
54
|
-
export
|
|
54
|
+
export type HoisterTree = {
|
|
55
55
|
name: PackageName;
|
|
56
56
|
identName: PackageName;
|
|
57
57
|
reference: string;
|
|
@@ -60,13 +60,13 @@ export declare type HoisterTree = {
|
|
|
60
60
|
hoistPriority?: number;
|
|
61
61
|
dependencyKind?: HoisterDependencyKind;
|
|
62
62
|
};
|
|
63
|
-
export
|
|
63
|
+
export type HoisterResult = {
|
|
64
64
|
name: PackageName;
|
|
65
65
|
identName: PackageName;
|
|
66
66
|
references: Set<string>;
|
|
67
67
|
dependencies: Set<HoisterResult>;
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
type Locator = string;
|
|
70
70
|
declare enum DebugLevel {
|
|
71
71
|
NONE = -1,
|
|
72
72
|
PERF = 0,
|
|
@@ -74,7 +74,7 @@ declare enum DebugLevel {
|
|
|
74
74
|
REASONS = 2,
|
|
75
75
|
INTENSIVE_CHECK = 9
|
|
76
76
|
}
|
|
77
|
-
export
|
|
77
|
+
export type HoistOptions = {
|
|
78
78
|
/** Runs self-checks after hoisting is finished */
|
|
79
79
|
check?: boolean;
|
|
80
80
|
/** Debug level */
|
package/lib/hoist.js
CHANGED
|
@@ -6,7 +6,7 @@ var HoisterDependencyKind;
|
|
|
6
6
|
HoisterDependencyKind[HoisterDependencyKind["REGULAR"] = 0] = "REGULAR";
|
|
7
7
|
HoisterDependencyKind[HoisterDependencyKind["WORKSPACE"] = 1] = "WORKSPACE";
|
|
8
8
|
HoisterDependencyKind[HoisterDependencyKind["EXTERNAL_SOFT_LINK"] = 2] = "EXTERNAL_SOFT_LINK";
|
|
9
|
-
})(HoisterDependencyKind
|
|
9
|
+
})(HoisterDependencyKind || (exports.HoisterDependencyKind = HoisterDependencyKind = {}));
|
|
10
10
|
var Hoistable;
|
|
11
11
|
(function (Hoistable) {
|
|
12
12
|
Hoistable[Hoistable["YES"] = 0] = "YES";
|
|
@@ -442,7 +442,7 @@ const getNodeHoistInfo = (rootNode, rootNodePathLocators, nodePath, node, usedDe
|
|
|
442
442
|
if (!usedDep || origDep.ident !== usedDep.ident) {
|
|
443
443
|
isHoistable = false;
|
|
444
444
|
if (outputReason)
|
|
445
|
-
reason = `- previously hoisted dependency mismatch, needed: ${prettyPrintLocator(origDep.locator)}, available: ${prettyPrintLocator(usedDep
|
|
445
|
+
reason = `- previously hoisted dependency mismatch, needed: ${prettyPrintLocator(origDep.locator)}, available: ${prettyPrintLocator(usedDep?.locator)}`;
|
|
446
446
|
break;
|
|
447
447
|
}
|
|
448
448
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export type { NodeModulesBaseNode, NodeModulesPackageNode, NodeModulesTreeOption
|
|
|
4
4
|
export { NodeModulesHoistingLimits, } from './buildNodeModulesTree';
|
|
5
5
|
export { buildNodeModulesTree, buildLocatorMap, getArchivePath, };
|
|
6
6
|
export type { NodeModulesLocatorMap };
|
|
7
|
+
export type { HoisterTree, HoisterResult } from './hoist';
|
|
8
|
+
export { hoist, HoisterDependencyKind } from './hoist';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getArchivePath = exports.buildLocatorMap = exports.buildNodeModulesTree = exports.NodeModulesHoistingLimits = void 0;
|
|
3
|
+
exports.HoisterDependencyKind = exports.hoist = exports.getArchivePath = exports.buildLocatorMap = exports.buildNodeModulesTree = exports.NodeModulesHoistingLimits = void 0;
|
|
4
4
|
const buildNodeModulesTree_1 = require("./buildNodeModulesTree");
|
|
5
5
|
Object.defineProperty(exports, "getArchivePath", { enumerable: true, get: function () { return buildNodeModulesTree_1.getArchivePath; } });
|
|
6
6
|
const buildNodeModulesTree_2 = require("./buildNodeModulesTree");
|
|
@@ -8,3 +8,6 @@ Object.defineProperty(exports, "buildNodeModulesTree", { enumerable: true, get:
|
|
|
8
8
|
Object.defineProperty(exports, "buildLocatorMap", { enumerable: true, get: function () { return buildNodeModulesTree_2.buildLocatorMap; } });
|
|
9
9
|
var buildNodeModulesTree_3 = require("./buildNodeModulesTree");
|
|
10
10
|
Object.defineProperty(exports, "NodeModulesHoistingLimits", { enumerable: true, get: function () { return buildNodeModulesTree_3.NodeModulesHoistingLimits; } });
|
|
11
|
+
var hoist_1 = require("./hoist");
|
|
12
|
+
Object.defineProperty(exports, "hoist", { enumerable: true, get: function () { return hoist_1.hoist; } });
|
|
13
|
+
Object.defineProperty(exports, "HoisterDependencyKind", { enumerable: true, get: function () { return hoist_1.HoisterDependencyKind; } });
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/nm",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
|
-
"
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js",
|
|
8
|
+
"./package.json": "./package.json"
|
|
9
|
+
},
|
|
7
10
|
"sideEffects": false,
|
|
8
11
|
"dependencies": {
|
|
9
|
-
"@yarnpkg/core": "^4.0.
|
|
10
|
-
"@yarnpkg/fslib": "^3.0.
|
|
11
|
-
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"@yarnpkg/pnp": "^4.0.0-rc.9"
|
|
12
|
+
"@yarnpkg/core": "^4.0.2",
|
|
13
|
+
"@yarnpkg/fslib": "^3.0.1",
|
|
14
|
+
"@yarnpkg/pnp": "^4.0.1"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
17
|
"postpack": "rm -rf lib",
|
|
@@ -20,7 +21,10 @@
|
|
|
20
21
|
},
|
|
21
22
|
"publishConfig": {
|
|
22
23
|
"main": "./lib/index.js",
|
|
23
|
-
"
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./lib/index.js",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
}
|
|
24
28
|
},
|
|
25
29
|
"files": [
|
|
26
30
|
"/lib/**/*"
|
|
@@ -31,7 +35,6 @@
|
|
|
31
35
|
"directory": "packages/yarnpkg-nm"
|
|
32
36
|
},
|
|
33
37
|
"engines": {
|
|
34
|
-
"node": ">=
|
|
35
|
-
}
|
|
36
|
-
"stableVersion": "3.0.1"
|
|
38
|
+
"node": ">=18.12.0"
|
|
39
|
+
}
|
|
37
40
|
}
|