@yarnpkg/nm 4.0.0-rc.3 → 4.0.0-rc.31

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.
@@ -10,10 +10,10 @@ export declare enum NodeModulesHoistingLimits {
10
10
  DEPENDENCIES = "dependencies",
11
11
  NONE = "none"
12
12
  }
13
- export declare type NodeModulesBaseNode = {
13
+ export type NodeModulesBaseNode = {
14
14
  dirList: Set<Filename>;
15
15
  };
16
- export declare type NodeModulesPackageNode = {
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 declare type NodeModulesTree = Map<PortablePath, NodeModulesBaseNode | NodeModulesPackageNode>;
34
- export declare type NodeModulesTreeErrors = Array<{
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
- declare type LocatorKey = string;
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 declare type NodeModulesLocatorMap = Map<LocatorKey, {
68
+ export type NodeModulesLocatorMap = Map<LocatorKey, {
69
69
  target: PortablePath;
70
70
  linkType: LinkType;
71
71
  locations: Array<PortablePath>;
@@ -402,9 +402,11 @@ const populateNodeModulesTree = (pnp, hoistedTree, options) => {
402
402
  if (seenNodes.has(pkg))
403
403
  return;
404
404
  seenNodes.add(pkg);
405
+ const pkgReferences = Array.from(pkg.references).sort().join(`#`);
405
406
  for (const dep of pkg.dependencies) {
407
+ const depReferences = Array.from(dep.references).sort().join(`#`);
406
408
  // We do not want self-references in node_modules, since they confuse existing tools
407
- if (dep === pkg)
409
+ if (dep.identName === pkg.identName && depReferences === pkgReferences)
408
410
  continue;
409
411
  const references = Array.from(dep.references).sort();
410
412
  const locator = { name: dep.identName, reference: references[0] };
@@ -422,7 +424,8 @@ const populateNodeModulesTree = (pnp, hoistedTree, options) => {
422
424
  const workspace = options.project.workspacesByCwd.get(leafNode.target.slice(0, -1));
423
425
  isAnonymousWorkspace = !!(workspace && !workspace.manifest.name);
424
426
  }
425
- if (!dep.name.endsWith(WORKSPACE_NAME_SUFFIX) && !isAnonymousWorkspace) {
427
+ const isCircularSymlink = leafNode.linkType === LinkType.SOFT && nodeModulesLocation.startsWith(leafNode.target);
428
+ if (!dep.name.endsWith(WORKSPACE_NAME_SUFFIX) && !isAnonymousWorkspace && !isCircularSymlink) {
426
429
  const prevNode = tree.get(nodeModulesLocation);
427
430
  if (prevNode) {
428
431
  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
- declare type PackageName = string;
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 declare type HoisterTree = {
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 declare type HoisterResult = {
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
- declare type Locator = string;
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 declare type HoistOptions = {
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,17 @@
1
1
  {
2
2
  "name": "@yarnpkg/nm",
3
- "version": "4.0.0-rc.3",
3
+ "version": "4.0.0-rc.31",
4
4
  "license": "BSD-2-Clause",
5
5
  "main": "./lib/index.js",
6
- "types": "./lib/index.d.ts",
6
+ "exports": {
7
+ ".": "./lib/index.js",
8
+ "./package.json": "./package.json"
9
+ },
7
10
  "sideEffects": false,
8
11
  "dependencies": {
9
- "@yarnpkg/core": "^4.0.0-rc.3",
10
- "@yarnpkg/fslib": "^3.0.0-rc.3"
11
- },
12
- "devDependencies": {
13
- "@yarnpkg/pnp": "^4.0.0-rc.3"
12
+ "@yarnpkg/core": "^4.0.0-rc.31",
13
+ "@yarnpkg/fslib": "^3.0.0-rc.31",
14
+ "@yarnpkg/pnp": "^4.0.0-rc.31"
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
- "types": "./lib/index.d.ts"
24
+ "exports": {
25
+ ".": "./lib/index.js",
26
+ "./package.json": "./package.json"
27
+ }
24
28
  },
25
29
  "files": [
26
30
  "/lib/**/*"