@yarnpkg/nm 3.0.1 → 3.0.2

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/hoist.d.ts DELETED
@@ -1,96 +0,0 @@
1
- /**
2
- * High-level node_modules hoisting algorithm recipe
3
- *
4
- * 1. Take input dependency graph and start traversing it,
5
- * as you visit new node in the graph - clone it if there can be multiple paths
6
- * to access the node from the graph root to the node, e.g. essentially represent
7
- * the graph with a tree as you go, to make hoisting possible.
8
- * 2. You want to hoist every node possible to the top root node first,
9
- * then to each of its children etc, so you need to keep track what is your current
10
- * root node into which you are hoisting
11
- * 3. Traverse the dependency graph from the current root node and for each package name
12
- * that can be potentially hoisted to the current root node build a list of idents
13
- * in descending hoisting preference. You will check in next steps whether most preferred ident
14
- * for the given package name can be hoisted first, and if not, then you check the
15
- * less preferred ident, etc, until either some ident will be hoisted
16
- * or you run out of idents to check
17
- * (no need to convert the graph to the tree when you build this preference map).
18
- * 4. The children of the root node are already "hoisted", so you need to start
19
- * from the dependencies of these children. You take some child and
20
- * sort its dependencies so that regular dependencies without peer dependencies
21
- * will come first and then those dependencies that peer depend on them.
22
- * This is needed to make algorithm more efficient and hoist nodes which are easier
23
- * to hoist first and then handle peer dependent nodes.
24
- * 5. You take this sorted list of dependencies and check if each of them can be
25
- * hoisted to the current root node. To answer is the node can be hoisted you check
26
- * your constraints - require promise and peer dependency promise.
27
- * The possible answers can be: YES - the node is hoistable to the current root,
28
- * NO - the node is not hoistable to the current root
29
- * and DEPENDS - the node is hoistable to the root if nodes X, Y, Z are hoistable
30
- * to the root. The case DEPENDS happens when all the require and other
31
- * constraints are met, except peer dependency constraints. Note, that the nodes
32
- * that are not package idents currently at the top of preference list are considered
33
- * to have the answer NO right away, before doing any other constraint checks.
34
- * 6. When you have hoistable answer for each dependency of a node you then build
35
- * a list of nodes that are NOT hoistable. These are the nodes that have answer NO
36
- * and the nodes that DEPENDS on these nodes. All the other nodes are hoistable,
37
- * those that have answer YES and those that have answer DEPENDS,
38
- * because they are cyclically dependent on each another
39
- * 7. You hoist all the hoistable nodes to the current root and continue traversing
40
- * the tree. Note, you need to track newly added nodes to the current root,
41
- * because after you finished tree traversal you want to come back to these new nodes
42
- * first thing and hoist everything from each of them to the current tree root.
43
- * 8. After you have finished traversing newly hoisted current root nodes
44
- * it means you cannot hoist anything to the current tree root and you need to pick
45
- * the next node as current tree root and run the algorithm again
46
- * until you run out of candidates for current tree root.
47
- */
48
- declare type PackageName = string;
49
- export declare enum HoisterDependencyKind {
50
- REGULAR = 0,
51
- WORKSPACE = 1,
52
- EXTERNAL_SOFT_LINK = 2
53
- }
54
- export declare type HoisterTree = {
55
- name: PackageName;
56
- identName: PackageName;
57
- reference: string;
58
- dependencies: Set<HoisterTree>;
59
- peerNames: Set<PackageName>;
60
- hoistPriority?: number;
61
- dependencyKind?: HoisterDependencyKind;
62
- };
63
- export declare type HoisterResult = {
64
- name: PackageName;
65
- identName: PackageName;
66
- references: Set<string>;
67
- dependencies: Set<HoisterResult>;
68
- };
69
- declare type Locator = string;
70
- declare enum DebugLevel {
71
- NONE = -1,
72
- PERF = 0,
73
- CHECK = 1,
74
- REASONS = 2,
75
- INTENSIVE_CHECK = 9
76
- }
77
- export declare type HoistOptions = {
78
- /** Runs self-checks after hoisting is finished */
79
- check?: boolean;
80
- /** Debug level */
81
- debugLevel?: DebugLevel;
82
- /** Hoist borders are defined by parent node locator and its dependency name. The dependency is considered a border, nothing can be hoisted past this dependency, but dependency can be hoisted */
83
- hoistingLimits?: Map<Locator, Set<PackageName>>;
84
- };
85
- /**
86
- * Hoists package tree.
87
- *
88
- * The root node of a tree must has id: '.'.
89
- * This function does not mutate its arguments, it hoists and returns tree copy.
90
- *
91
- * @param tree package tree (cycles in the tree are allowed)
92
- *
93
- * @returns hoisted tree copy
94
- */
95
- export declare const hoist: (tree: HoisterTree, opts?: HoistOptions) => HoisterResult;
96
- export {};