You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If target split on "/" or "\" contains any ".", ".." or
"node_modules" segments after the first segment, throw an
Invalid Package Target error.
Let resolvedTarget be the URL resolution of the concatenation of
packageURL and target.
Assert: resolvedTarget is contained in packageURL.
If subpath split on "/" or "\" contains any ".", ".." or
"node_modules" segments, throw an Invalid Module Specifier error.
If pattern is true, then
Return the URL resolution of resolvedTarget with every instance of
"*" replaced with subpath.
Otherwise,
Return the URL resolution of the concatenation of subpath and
resolvedTarget.
Otherwise, if target is a non-null Object, then
If exports contains any index property keys, as defined in ECMA-262
6.1.7 Array Index, throw an Invalid Package Configuration error.
For each property p of target, in object insertion order as,
If p equals "default" or conditions contains an entry for p,
then
Let targetValue be the value of the p property in target.
Let resolved be the result of PACKAGE_TARGET_RESOLVE(
packageURL, targetValue, subpath, pattern, internal,
conditions).
If resolved is equal to undefined, continue the loop.
Return resolved.
Return undefined.
Otherwise, if target is an Array, then
If _target.length is zero, return null.
For each item targetValue in target, do
Let resolved be the result of PACKAGE_TARGET_RESOLVE(
packageURL, targetValue, subpath, pattern, internal,
conditions), continuing the loop on any Invalid Package Target
error.
If resolved is undefined, continue the loop.
Return resolved.
Return or throw the last fallback resolution null return or error.
Otherwise, if target is null, return null.
Otherwise throw an Invalid Package Target error.
ESM_FORMAT(url)
Assert: url corresponds to an existing file.
Let pjson be the result of READ_PACKAGE_SCOPE(url).
If url ends in ".mjs", then
Return "module".
If url ends in ".cjs", then
Return "commonjs".
If pjson?.type exists and is "module", then
If url ends in ".js", then
Return "module".
Throw an Unsupported File Extension error.
Otherwise,
Throw an Unsupported File Extension error.
READ_PACKAGE_SCOPE(url)
Let scopeURL be url.
While scopeURL is not the file system root,
Set scopeURL to the parent URL of scopeURL.
If scopeURL ends in a "node_modules" path segment, return null.
Let pjson be the result of READ_PACKAGE_JSON(scopeURL).
If pjson is not null, then
Return pjson.
Return null.
READ_PACKAGE_JSON(packageURL)
Let pjsonURL be the resolution of "package.json" within packageURL.
If the file at pjsonURL does not exist, then
Return null.
If the file at packageURL does not parse as valid JSON, then
Throw an Invalid Package Configuration error.
Return the parsed JSON source of the file at pjsonURL.
The text was updated successfully, but these errors were encountered:
Please implement the algo or enable a hook that gets called with importSpecifier and pathOfImporter
from https://nodejs.org/api/esm.html#esm_resolver_algorithm
ESM_RESOLVE(specifier, parentURL)
PACKAGE_RESOLVE(packageSpecifier, parentURL)
PACKAGE_SELF_RESOLVE(packageName, packageSubpath, parentURL)
PACKAGE_EXPORTS_RESOLVE(packageURL, subpath, exports, conditions)
PACKAGE_IMPORTS_RESOLVE(specifier, parentURL, conditions)
PACKAGE_IMPORTS_EXPORTS_RESOLVE(matchKey, matchObj, packageURL, isImports, conditions)
PACKAGE_TARGET_RESOLVE(packageURL, target, subpath, pattern, internal, conditions)
ESM_FORMAT(url)
READ_PACKAGE_SCOPE(url)
READ_PACKAGE_JSON(packageURL)
The text was updated successfully, but these errors were encountered: