The checksum for the fetch result.
If true, the package location won't be considered for package lookups (so
for example with can use this flag to indicate that the link:
protocol
should be resolvable, but should never be used to detect the package that
owns a path).
The "true" place where we can find the sources. We use that in order to
compute the file:
and link:
relative paths.
The path where the package can be found within the packageFs
. This is
typically the node_modules/<scope>/<name>
path.
If set, this function will be called once the fetch result isn't needed anymore. Typically used to release the ZipFS memory.
A set of data that are preserved from one install to the next. Linkers are allowed to cache whatever they want (including ES-native data structures like Map and Set) as long as they remember to follow basic rules:
They have to be prepared for no custom data to be passed at all; Yarn is allowed to clear the cache at will.
They have to cache only things that are unlikely to change. For instance
caching the packages' scripts
field is fine, but caching their
dependencies isn't (first because dependencies are provided by the core
itself, so caching wouldn't make sense, but also because users may
change the dependencies of any package via the resolutions
field).
And of course, they have to manage their own migration.
They have to be prepared for no custom data to be passed at all; Yarn is allowed to clear the cache at will.
They have to cache only things that are unlikely to change. For instance
caching the packages' scripts
field is fine, but caching their
dependencies isn't (first because dependencies are provided by the core
itself, so caching wouldn't make sense, but also because users may
change the dependencies of any package via the resolutions
field).
And of course, they have to manage their own migration.
A list of extra package instances that may have been installed on the disk. While we usually recommend to avoid this feature (one package should only be installed once in a project, virtual dependencies excluded), it may be required to duplicate installs in some cases - for instance to replicate the hoisting that would happen with the node-modules linking strategy.
Unique hash of a package descriptor. Used as key in various places so that two descriptors can be quickly compared.
Instance of the cache that the project will use when packages have to be fetched. Some fetches may occur even during the resolution, for example when resolving git packages.
An optional override for the default fetching pipeline. This is for overrides only - if you need to add resolvers, prefer adding them through regular plugins instead.
If true, Yarn will check that the lockfile won't change after the
resolution step. Additionally, after the link step, Yarn will retrieve
the list of files in immutablePatterns
and check that they didn't get
modified either.
If true, Yarn will exclusively use the lockfile metadata. Setting this flag will cause it to ignore any change in the manifests, and to abort if any dependency isn't present in the lockfile.
Changes which artifacts are generated during the install. Check the enumeration documentation for details.
If true (the default), Yarn will update the workspace manifests once the install has completed.
Provide a report instance that'll be use to store the information emitted during the install process.
An optional override for the default resolution pipeline. This is for overrides only - if you need to add resolvers, prefer adding them through regular plugins instead.
The core reclaims the virtual filesystem by default when the
installPackage
function returns. This may be annoying when working on
parallel installers, since installPackage
are guaranteed to work
sequentially (and thus no two packages could be installed at the same
time, since one's fs would be closed as soon as the second would start).
To avoid that, you can call the holdFetchResult
function from this extra
API to indicate to the core that it shouldn't reclaim the filesystem until
the API passed in parameter as finished executing. Note that this may lead
to higher memory consumption (since multiple packages may be kept in
memory), so you'll need to implement an upper bound to the number of
concurrent package installs.
To avoid that, you can call the holdFetchResult
function from this extra
API to indicate to the core that it shouldn't reclaim the filesystem until
the API passed in parameter as finished executing. Note that this may lead
to higher memory consumption (since multiple packages may be kept in
memory), so you'll need to implement an upper bound to the number of
concurrent package installs.
Unique hash of a package locator. Used as key in various places so that two locators can be quickly compared.
Whether to parse the selector as a query string
Throw an error if bindings are missing
Throw an error if the protocol is missing or is not the specified one
Throw an error if the source is missing
The RegExp from https://semver.org/ but modified to
(?:[\sv=]*?)
(?:\s*)
Given a folder, prepares this project for use. Runs yarn install
then
yarn build
if a package.json
is found.
Add support support for the logFilters
setting to the specified Report
instance.
This function is worth some documentation. It takes a set of packages, traverses them all, and generates virtual packages for each package that lists peer dependencies.
We also take advantage of the tree traversal to detect which packages are actually used and which have disappeared, and to know which packages truly have an optional build (since a package may be optional in one part of the tree but not another).
We also take advantage of the tree traversal to detect which packages are actually used and which have disappeared, and to know which packages truly have an optional build (since a package may be optional in one part of the tree but not another).
Returns true
if the descriptors are equal
Some descriptors only make sense when bound with some internal state. For
instance that would be the case for the file:
ranges, which require to
be bound to their parent packages in order to resolve relative paths from
the right location.
This function will apply the specified parameters onto the requested descriptor, but only if it didn't get bound before (important to handle the case where we replace a descriptor by another, since when that happens the replacement has probably been already bound).
This function will apply the specified parameters onto the requested descriptor, but only if it didn't get bound before (important to handle the case where we replace a descriptor by another, since when that happens the replacement has probably been already bound).
The original descriptor
The parameters to encode in the range
Some locators only make sense when bound with some internal state. For
instance that would be the case for the file:
references, which require to
be bound to their parent packages in order to resolve relative paths from
the right location.
This function will apply the specified parameters onto the requested locator, but only if it didn't get bound before (important to handle the case where we replace a locator by another, since when that happens the replacement has probably been already bound).
This function will apply the specified parameters onto the requested locator, but only if it didn't get bound before (important to handle the case where we replace a locator by another, since when that happens the replacement has probably been already bound).
The original locator
The parameters to encode in the reference
Combines an Array of glob patterns into a regular expression.
An array of glob patterns
A string
representing a regular expression or null
if no glob patterns are provided
Cleans the potential version by removing leading/trailing whitespace and '=v' prefix
A valid SemVer string, otherwise null
Turns a descriptor into a locator.
Note that this process may be unsafe, as descriptors may reference multiple
packages, putting them at odd with locators' expected semantic. Only makes
sense when used with single-resolution protocols, for instance file:
.
Note that this process may be unsafe, as descriptors may reference multiple
packages, putting them at odd with locators' expected semantic. Only makes
sense when used with single-resolution protocols, for instance file:
.
The descriptor to convert into a locator.
Turns a locator into a descriptor.
This should be safe to do regardless of the locator, since all locator references are expected to be valid descriptor ranges.
This should be safe to do regardless of the locator, since all locator references are expected to be valid descriptor ranges.
The locator to convert into a descriptor.
Converts Maps to indexable objects recursively.
Turns a package structure into a simple locator. You won't often need to call this function since packages are already valid locators by virtue of structural inheritance.
This function is only useful if you absolutely need to remove the non-locator fields from a structure before storing it somewhere.
This function is only useful if you absolutely need to remove the non-locator fields from a structure before storing it somewhere.
The package to convert into a locator.
Turns a compatible source to an ident. You won't really have to use this function since by virtue of structural inheritance all descriptors and locators are already valid idents.
This function is only useful if you absolutely need to remove the non-ident fields from a structure before storing it somewhere.
This function is only useful if you absolutely need to remove the non-ident fields from a structure before storing it somewhere.
The data structure to convert into an ident.
Some bindings are internal-only and not meant to be displayed anywhere (for
instance that's the case with the parent locator bound to the file:
ranges).
this function strips them from a range.
this function strips them from a range.
Returns a new devirtualized descriptor based on a virtualized descriptor
Requires a module without using the cache if it has changed since the last time it was loaded
Requires a module without using the module cache
Execute a binary from the specified package.
Note that "binary" in this sense means "a Javascript file". Actual native binaries cannot be executed this way, because we use Node in order to transparently read from the archives.
Note that "binary" in this sense means "a Javascript file". Actual native binaries cannot be executed this way, because we use Node in order to transparently read from the archives.
The queried package
The name of the binary file to execute
The arguments to pass to the file
Execute a binary from the specified workspace
The queried package
The name of the binary file to execute
The arguments to pass to the file
The presence of a node_modules
directory in the path is extremely common
in the JavaScript ecosystem to denote whether a path belongs to a vendor
or not. I considered using a more generic path for packages that aren't
always JS-only (such as when using the Git fetcher), but that unfortunately
caused various JS apps to start showing errors when working with git repos.
As a result, all packages from all languages will follow this convention. At least it'll be consistent, and linkers will always have the ability to remap them to a different location if that's a critical requirement.
As a result, all packages from all languages will follow this convention. At least it'll be consistent, and linkers will always have the ability to remap them to a different location if that's a critical requirement.
Searches through networkSettings and returns the most specific match
Return the binaries that can be accessed by the specified package
The queried package
The project owning the package
Returns whether the given package is compatible with the specified environment.
Returns true
if the descriptor is virtual.
Returns true
if the locator is virtual.
Creates a package descriptor.
The base ident (see makeIdent
)
The range to attach (eg. ^1.0.0
)
Creates a package ident.
The package scope without the @
prefix (eg. types
)
The name of the package
Turn the components returned by parseRange
back into a string. Check
parseRange
for more details.
Parses a string
into a descriptor
Throws an error if the descriptor cannot be parsed.
Throws an error if the descriptor cannot be parsed.
The descriptor string (eg. lodash@^1.0.0
)
If false
, the range is optional (unknown
will be used as fallback)
File-style ranges are bound to a parent locators that we need in order to
resolve relative paths to the location of their parent packages. This
function wraps parseRange
to automatically extract the parent locator
from the bindings and return it along with the selector.
Parses a string into an ident.
Throws an error if the ident cannot be parsed.
Throws an error if the ident cannot be parsed.
The ident string (eg. @types/lodash
)
Parses a string
into a locator
Throws an error if the locator cannot be parsed.
Throws an error if the locator cannot be parsed.
The locator string
(eg. lodash@1.0.0
)
If false
, the reference is optional (unknown
will be used as fallback)
Parses a range into its constituents. Ranges typically follow these forms,
with both protocol
and bindings
being optionals:
The selector is intended to "refine" the source, and is required. The source itself is optional (for instance we don't need it for npm packages, but we do for git dependencies).
The selector is intended to "refine" the source, and is required. The source itself is optional (for instance we don't need it for npm packages, but we do for git dependencies).
Returns a string that is suitable to be printed to stdout. Based on the configuration it may include color sequences.
Reference configuration
The locator to pretty print
The descriptor that depends on it
Returns a string that is suitable to be printed to stdout. Based on the configuration it may include color sequences.
Reference configuration
The descriptor to pretty print
Returns a string that is suitable to be printed to stdout. Based on the configuration it may include color sequences.
Reference configuration
The ident to pretty print
Returns a string that is suitable to be printed to stdout. Based on the configuration it may include color sequences.
Reference configuration
The locator to pretty print
Returns a string that is suitable to be printed to stdout. It will never be colored.
The locator to pretty print
Returns a string that is suitable to be printed to stdout. Based on the configuration it may include color sequences.
Reference configuration
Returns a string that is suitable to be printed to stdout. Based on the configuration it may include color sequences.
Reference configuration
The reference to pretty print
Returns a string that is suitable to be printed to stdout. Based on the configuration it may include color sequences.
Reference configuration
The descriptor to pretty print
The locator is resolves to
Returns a string that is suitable to be printed to stdout. Based on the configuration it may include color sequences.
Reference configuration
The workspace to pretty print
Returns whether the given semver version satisfies the given range. Notably this supports prerelease versions so that "2.0.0-rc.0" satisfies the range ">=1.0.0", for example.
This function exists because the semver.satisfies method does not include
pre releases. This means ranges such as * would not satisfy 1.0.0-rc. The
includePrerelease flag has a weird behavior and cannot be used (if you want
to try it out, just run the semverUtils
testsuite using this flag instead
of our own implementation, and you'll see the failing cases).
See https://github.com/yarnpkg/berry/issues/575 for more context.
This function exists because the semver.satisfies method does not include
pre releases. This means ranges such as * would not satisfy 1.0.0-rc. The
includePrerelease flag has a weird behavior and cannot be used (if you want
to try it out, just run the semverUtils
testsuite using this flag instead
of our own implementation, and you'll see the failing cases).
See https://github.com/yarnpkg/berry/issues/575 for more context.
Returns a string from an ident, formatted as a slug (eg. @types-lodash
).
Returns a string from a locator, formatted as a slug (eg. @types-lodash-npm-1.0.0-abcdef1234
).
Sorts a list of descriptors, first by their idents then by their ranges.
Returns a string from a descriptor (eg. @types/lodash@^1.0.0
).
Returns a string from an ident (eg. @types/lodash
).
Returns a string from a descriptor (eg. @types/lodash@1.0.0
).
Parses a string
into a descriptor
Returns null
if the descriptor cannot be parsed.
Returns null
if the descriptor cannot be parsed.
The descriptor string (eg. lodash@^1.0.0
)
If false
, the range is optional (unknown
will be used as fallback)
Parses a string into an ident.
Returns null
if the ident cannot be parsed.
Returns null
if the ident cannot be parsed.
The ident string (eg. @types/lodash
)
Parses a string
into a locator
Returns null
if the locator cannot be parsed.
Returns null
if the locator cannot be parsed.
The locator string (eg. lodash@1.0.0
)
If false
, the reference is optional (unknown
will be used as fallback)
A cached version of new semver.Range(potentialRange)
that returns null
on invalid ranges
Creates a new virtual descriptor from a non virtual one.
The descriptor to virtualize
A hash that provides uniqueness to this virtualized descriptor (normally a locator hash)
Generated using TypeDoc
Unique hash of a package descriptor. Used as key in various places so that two descriptors can be quickly compared.