Debug level
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
Package locator key for usage inside maps
Node modules tree - a map of every folder within the node_modules, along with their directory listing and whether they are a symlink and their location.
Sample contents: /home/user/project/node_modules -> {dirList: ['foo', 'bar']} /home/user/project/node_modules/foo -> {target: '/home/user/project/.yarn/.cache/foo.zip/node_modules/foo', linkType: 'HARD'} /home/user/project/node_modules/bar -> {target: '/home/user/project/packages/bar', linkType: 'SOFT'}
Sample contents: /home/user/project/node_modules -> {dirList: ['foo', 'bar']} /home/user/project/node_modules/foo -> {target: '/home/user/project/.yarn/.cache/foo.zip/node_modules/foo', linkType: 'HARD'} /home/user/project/node_modules/bar -> {target: '/home/user/project/packages/bar', linkType: 'SOFT'}
High-level node_modules hoisting algorithm recipe
Mapping which packages depend on a given package alias + ident. It is used to determine hoisting weight, e.g. which one among the group of packages with the same name should be hoisted. The package having the biggest number of parents using this package will be hoisted.
node_modules path segment
The workspace name suffix used internally by this implementation and appeneded to the name of workspace package. It is needed to create and distinguuish special nodes for workspaces
Benchmarks node_modules tree building.
The function is used for troubleshooting purposes only.
The function is used for troubleshooting purposes only.
average raw hoisting time
Benchmarks raw hoisting performance.
The function is used for troubleshooting purposes only.
The function is used for troubleshooting purposes only.
package tree
average raw hoisting time
Retrieve full package list and build hoisted node_modules
directories
representation in-memory.
PnP API
hoisted node_modules
directories representation in-memory
Traverses PnP tree and produces input for the RawHoister
PnP API
package tree, packages info and locators
Builds mapping, where key is an alias + dependent package ident and the value is the list of parent package idents who depend on this package.
package tree root node
preference map
Builds a map representing layout of nested workspaces and internal portals on the file system.
Creates a clone of package tree with extra fields used for hoisting purposes.
package tree clone
This method clones the node and returns cloned node copy, if the node was not previously decoupled.
The node is considered decoupled if there is no multiple parents to any node on the path from the dependency graph root up to this node. This means that there are no other nodes in dependency graph that somehow transitively use this node and hence node can be hoisted without side effects.
The process of node decoupling is done by going from root node of the graph up to the node in concern and decoupling each node on this graph path.
The node is considered decoupled if there is no multiple parents to any node on the path from the dependency graph root up to this node. This means that there are no other nodes in dependency graph that somehow transitively use this node and hence node can be hoisted without side effects.
The process of node decoupling is done by going from root node of the graph up to the node in concern and decoupling each node on this graph path.
original node
decoupled node
Pretty-prints dependency tree in the yarn why
-like format
The function is used for troubleshooting purposes only.
The function is used for troubleshooting purposes only.
sorted node_modules tree
Pretty-prints dependency tree in the yarn why
-like format
The function is used for troubleshooting purposes only.
The function is used for troubleshooting purposes only.
sorted node_modules tree
Pretty-prints node_modules tree.
The function is used for troubleshooting purposes only.
The function is used for troubleshooting purposes only.
node_modules tree
top-level project root folder
sorted node_modules tree
Returns path to archive, if package location is inside the archive.
package location
path to archive is location is insde the archive or null otherwise
Builds a map of most preferred packages that might be hoisted to the root node.
The values in the map are idents sorted by preference from most preferred to less preferred. If the root node has already some version of a package, the value array will contain only one element, since it is not possible for other versions of a package to be hoisted.
The values in the map are idents sorted by preference from most preferred to less preferred. If the root node has already some version of a package, the value array will contain only one element, since it is not possible for other versions of a package to be hoisted.
root node
preference map
Gets regular node dependencies only and sorts them in the order so that peer dependencies come before the dependency that rely on them.
graph node
sorted regular dependencies
Hoists package tree.
The root node of a tree must has id: '.'. This function does not mutate its arguments, it hoists and returns tree copy.
The root node of a tree must has id: '.'. This function does not mutate its arguments, it hoists and returns tree copy.
package tree (cycles in the tree are allowed)
hoisted tree copy
Performs actual graph transformation, by hoisting packages to the root node.
dependency tree
root node path in the tree
a set of locators for nodes that lead from the top of the tree up to root node
map of dependency nodes from parents of root node used by root node and its children via parent lookup
idents that should be attempted to be hoisted to the root node
Performs hoisting all the dependencies down the tree to the root node.
The algorithm used here reduces dependency graph by deduplicating instances of the packages while keeping:
package.json
The regular and peer dependency promises are kept while performing transform
on tree branches of packages at a time:
root package
-> parent package 1
... parent package n
-> dependency
We check wether we can hoist dependency
to root package
, this boils down basically
to checking:
root package
does not depend on other version of dependency
dependency
had already been hoisted from all parent packages
If many versions of the dependency
can be hoisted to the root package
we choose the most used
dependency
version in the project among them.
This function mutates the tree.
The algorithm used here reduces dependency graph by deduplicating instances of the packages while keeping:
package.json
The regular and peer dependency promises are kept while performing transform
on tree branches of packages at a time:
root package
-> parent package 1
... parent package n
-> dependency
We check wether we can hoist dependency
to root package
, this boils down basically
to checking:
root package
does not depend on other version of dependency
dependency
had already been hoisted from all parent packages
If many versions of the dependency
can be hoisted to the root package
we choose the most used
dependency
version in the project among them.
This function mutates the tree.
package dependencies graph
root node path in the tree
a set of locators for nodes that lead from the top of the tree up to root node
hoisting options
Converts hoisted tree to node modules map
PnP API
hoisted package tree from RawHoister
node modules map
Creates a clone of hoisted package tree with extra fields removed
stripped down hoisted package tree clone
Generated using TypeDoc
Runs self-checks after hoisting is finished