diff --git a/doc/api/esm.md b/doc/api/esm.md index 8b371941c42cdc..c5cd3c366694e6 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -869,14 +869,12 @@ The resolver can throw the following errors: > 1. Throw an _Invalid Module Specifier_ error. > 7. Let _packageSubpath_ be _"."_ concatenated with the substring of > _packageSpecifier_ from the position at the length of _packageName_. -> 8. If _packageSubpath_ ends in _"/"_, then -> 1. Throw an _Invalid Module Specifier_ error. -> 9. Let _selfUrl_ be the result of +> 8. Let _selfUrl_ be the result of > **PACKAGE\_SELF\_RESOLVE**(_packageName_, _packageSubpath_, _parentURL_). -> 10. If _selfUrl_ is not **undefined**, return _selfUrl_. -> 11. While _parentURL_ is not the file system root, +> 9. If _selfUrl_ is not **undefined**, return _selfUrl_. +> 10. While _parentURL_ is not the file system root, > 1. Let _packageURL_ be the URL resolution of _"node\_modules/"_ -> concatenated with _packageSpecifier_, relative to _parentURL_. +> concatenated with _packageName_, relative to _parentURL_. > 2. Set _parentURL_ to the parent folder URL of _parentURL_. > 3. If the folder at _packageURL_ does not exist, then > 1. Continue the next loop iteration. @@ -890,7 +888,7 @@ The resolver can throw the following errors: > 1. Return the URL resolution of _main_ in _packageURL_. > 7. Otherwise, > 1. Return the URL resolution of _packageSubpath_ in _packageURL_. -> 12. Throw a _Module Not Found_ error. +> 11. Throw a _Module Not Found_ error. **PACKAGE\_SELF\_RESOLVE**(_packageName_, _packageSubpath_, _parentURL_) @@ -908,6 +906,8 @@ The resolver can throw the following errors: **PACKAGE\_EXPORTS\_RESOLVE**(_packageURL_, _subpath_, _exports_, _conditions_) +Note: This function is directly invoked by the CommonJS resolution algorithm. + > 1. If _exports_ is an Object with both a key starting with _"."_ and a key not > starting with _"."_, throw an _Invalid Package Configuration_ error. > 2. If _subpath_ is equal to _"."_, then @@ -931,6 +931,8 @@ The resolver can throw the following errors: **PACKAGE\_IMPORTS\_RESOLVE**(_specifier_, _parentURL_, _conditions_) +Note: This function is directly invoked by the CommonJS resolution algorithm. + > 1. Assert: _specifier_ begins with _"#"_. > 2. If _specifier_ is exactly equal to _"#"_ or starts with _"#/"_, then > 1. Throw an _Invalid Module Specifier_ error. @@ -947,14 +949,16 @@ The resolver can throw the following errors: **PACKAGE\_IMPORTS\_EXPORTS\_RESOLVE**(_matchKey_, _matchObj_, _packageURL_, _isImports_, _conditions_) -> 1. If _matchKey_ is a key of _matchObj_ and does not contain _"\*"_, then +> 1. If _matchKey_ ends in _"/"_, then +> 1. Throw an _Invalid Module Specifier_ error. +> 2. If _matchKey_ is a key of _matchObj_ and does not contain _"\*"_, then > 1. Let _target_ be the value of _matchObj_\[_matchKey_]. > 2. Return the result of **PACKAGE\_TARGET\_RESOLVE**(_packageURL_, > _target_, **null**, _isImports_, _conditions_). -> 2. Let _expansionKeys_ be the list of keys of _matchObj_ containing only a +> 3. Let _expansionKeys_ be the list of keys of _matchObj_ containing only a > single _"\*"_, sorted by the sorting function **PATTERN\_KEY\_COMPARE** > which orders in descending order of specificity. -> 3. For each key _expansionKey_ in _expansionKeys_, do +> 4. For each key _expansionKey_ in _expansionKeys_, do > 1. Let _patternBase_ be the substring of _expansionKey_ up to but excluding > the first _"\*"_ character. > 2. If _matchKey_ starts with but is not equal to _patternBase_, then @@ -969,7 +973,7 @@ _isImports_, _conditions_) > _matchKey_ minus the length of _patternTrailer_. > 3. Return the result of **PACKAGE\_TARGET\_RESOLVE**(_packageURL_, > _target_, _patternMatch_, _isImports_, _conditions_). -> 4. Return **null**. +> 5. Return **null**. **PATTERN\_KEY\_COMPARE**(_keyA_, _keyB_) diff --git a/doc/api/modules.md b/doc/api/modules.md index 1647bcaede2e9a..adc6bc3f712b18 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -347,7 +347,7 @@ require(X) from module at path Y b. STOP 2. If X begins with '/' a. set Y to the file system root -3. If X begins with './' or '/' or '../' +3. If X is equal to '.', or X begins with './', '/' or '../' a. LOAD_AS_FILE(Y + X) b. LOAD_AS_DIRECTORY(Y + X) c. THROW "not found"