@yarnpkg/nm 3.0.3 → 3.1.0
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 +5 -2
- package/lib/hoist.d.ts +5 -5
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -1
- package/package.json +4 -6
|
@@ -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>;
|
|
@@ -410,9 +410,11 @@ const populateNodeModulesTree = (pnp, hoistedTree, options) => {
|
|
|
410
410
|
if (seenNodes.has(pkg))
|
|
411
411
|
return;
|
|
412
412
|
seenNodes.add(pkg);
|
|
413
|
+
const pkgReferences = Array.from(pkg.references).sort().join(`#`);
|
|
413
414
|
for (const dep of pkg.dependencies) {
|
|
415
|
+
const depReferences = Array.from(dep.references).sort().join(`#`);
|
|
414
416
|
// We do not want self-references in node_modules, since they confuse existing tools
|
|
415
|
-
if (dep === pkg)
|
|
417
|
+
if (dep.identName === pkg.identName && depReferences === pkgReferences)
|
|
416
418
|
continue;
|
|
417
419
|
const references = Array.from(dep.references).sort();
|
|
418
420
|
const locator = { name: dep.identName, reference: references[0] };
|
|
@@ -430,7 +432,8 @@ const populateNodeModulesTree = (pnp, hoistedTree, options) => {
|
|
|
430
432
|
const workspace = options.project.workspacesByCwd.get(leafNode.target.slice(0, -1));
|
|
431
433
|
isAnonymousWorkspace = !!(workspace && !workspace.manifest.name);
|
|
432
434
|
}
|
|
433
|
-
|
|
435
|
+
const isCircularSymlink = leafNode.linkType === LinkType.SOFT && nodeModulesLocation.startsWith(leafNode.target);
|
|
436
|
+
if (!dep.name.endsWith(WORKSPACE_NAME_SUFFIX) && !isAnonymousWorkspace && !isCircularSymlink) {
|
|
434
437
|
const prevNode = tree.get(nodeModulesLocation);
|
|
435
438
|
if (prevNode) {
|
|
436
439
|
if (prevNode.dirList) {
|
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/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,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/nm",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
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.
|
|
10
|
-
"@yarnpkg/fslib": "^2.
|
|
11
|
-
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"@yarnpkg/pnp": "^3.2.1"
|
|
9
|
+
"@yarnpkg/core": "^3.3.0",
|
|
10
|
+
"@yarnpkg/fslib": "^2.9.0",
|
|
11
|
+
"@yarnpkg/pnp": "^3.2.5"
|
|
14
12
|
},
|
|
15
13
|
"scripts": {
|
|
16
14
|
"postpack": "rm -rf lib",
|