Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGuy Bedford <guybedford@gmail.com>2019-12-17 09:58:19 +0300
committerRuben Bridgewater <ruben@bridgewater.de>2020-01-03 18:22:04 +0300
commitbd047e827719805a709f62bddcf627634ef64440 (patch)
tree94d81211073aa2154d7a58eaaa3b3a8c58dcb5a9 /doc
parent4f32bbb8160434a6f7ccc09b56d3d87ec25db7f9 (diff)
module: self resolve bug fix and esm ordering
PR-URL: https://github.com/nodejs/node/pull/31009 Reviewed-By: Jan Krems <jan.krems@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/esm.md36
-rw-r--r--doc/api/modules.md13
2 files changed, 25 insertions, 24 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md
index 4898edfc3a9..9fb9f60b289 100644
--- a/doc/api/esm.md
+++ b/doc/api/esm.md
@@ -1207,6 +1207,9 @@ _defaultEnv_ is the conditional environment name priority array,
> 1. If _packageSubpath_ contains any _"."_ or _".."_ segments or percent
> encoded strings for _"/"_ or _"\\"_, then
> 1. Throw an _Invalid Specifier_ error.
+> 1. Set _selfUrl_ to the result of
+> **SELF_REFERENCE_RESOLVE**(_packageName_, _packageSubpath_, _parentURL_).
+> 1. If _selfUrl_ isn't empty, return _selfUrl_.
> 1. If _packageSubpath_ is _undefined_ and _packageName_ is a Node.js builtin
> module, then
> 1. Return the string _"node:"_ concatenated with _packageSpecifier_.
@@ -1228,30 +1231,27 @@ _defaultEnv_ is the conditional environment name priority array,
> 1. Return **PACKAGE_EXPORTS_RESOLVE**(_packageURL_,
> _packageSubpath_, _pjson.exports_).
> 1. Return the URL resolution of _packageSubpath_ in _packageURL_.
-> 1. Set _selfUrl_ to the result of
-> **SELF_REFERENCE_RESOLE**(_packageSpecifier_, _parentURL_).
-> 1. If _selfUrl_ isn't empty, return _selfUrl_.
> 1. Throw a _Module Not Found_ error.
-**SELF_REFERENCE_RESOLVE**(_specifier_, _parentURL_)
+**SELF_REFERENCE_RESOLVE**(_packageName_, _packageSubpath_, _parentURL_)
> 1. Let _packageURL_ be the result of **READ_PACKAGE_SCOPE**(_parentURL_).
> 1. If _packageURL_ is **null**, then
-> 1. Return an empty result.
+> 1. Return **undefined**.
> 1. Let _pjson_ be the result of **READ_PACKAGE_JSON**(_packageURL_).
-> 1. Set _name_ to _pjson.name_.
-> 1. If _name_ is empty, then return an empty result.
-> 1. If _name_ is equal to _specifier_, then
-> 1. Return the result of **PACKAGE_MAIN_RESOLVE**(_packageURL_, _pjson_).
-> 1. If _specifier_ starts with _name_ followed by "/", then
-> 1. Set _subpath_ to everything after the "/".
-> 1. If _pjson_ is not **null** and _pjson_ has an _"exports"_ key, then
-> 1. Let _exports_ be _pjson.exports_.
-> 1. If _exports_ is not **null** or **undefined**, then
-> 1. Return **PACKAGE_EXPORTS_RESOLVE**(_packageURL_, _subpath_,
-> _pjson.exports_).
-> 1. Return the URL resolution of _subpath_ in _packageURL_.
-> 1. Otherwise return an empty result.
+> 1. If _pjson_ does not include an _"exports"_ property, then
+> 1. Return **undefined**.
+> 1. If _pjson.name_ is equal to _packageName_, then
+> 1. If _packageSubpath_ is _undefined_, then
+> 1. Return the result of **PACKAGE_MAIN_RESOLVE**(_packageURL_, _pjson_).
+> 1. Otherwise,
+> 1. If _pjson_ is not **null** and _pjson_ has an _"exports"_ key, then
+> 1. Let _exports_ be _pjson.exports_.
+> 1. If _exports_ is not **null** or **undefined**, then
+> 1. Return **PACKAGE_EXPORTS_RESOLVE**(_packageURL_, _subpath_,
+> _pjson.exports_).
+> 1. Return the URL resolution of _subpath_ in _packageURL_.
+> 1. Otherwise, return **undefined**.
**PACKAGE_MAIN_RESOLVE**(_packageURL_, _pjson_)
diff --git a/doc/api/modules.md b/doc/api/modules.md
index 9dc5cd22248..bac8b21d775 100644
--- a/doc/api/modules.md
+++ b/doc/api/modules.md
@@ -160,9 +160,9 @@ require(X) from module at path Y
a. LOAD_AS_FILE(Y + X)
b. LOAD_AS_DIRECTORY(Y + X)
c. THROW "not found"
-4. LOAD_NODE_MODULES(X, dirname(Y))
-5. LOAD_SELF_REFERENCE(X, dirname(Y))
-6. THROW "not found"
+4. LOAD_SELF_REFERENCE(X, dirname(Y))
+5. LOAD_NODE_MODULES(X, dirname(Y))
+7. THROW "not found"
LOAD_AS_FILE(X)
1. If X is a file, load X as JavaScript text. STOP
@@ -205,9 +205,10 @@ NODE_MODULES_PATHS(START)
LOAD_SELF_REFERENCE(X, START)
1. Find the closest package scope to START.
-2. If no scope was found, throw "not found".
-3. If the name in `package.json` isn't a prefix of X, throw "not found".
-4. Otherwise, resolve the remainder of X relative to this package as if it
+2. If no scope was found, return.
+3. If the `package.json` has no "exports", return.
+4. If the name in `package.json` isn't a prefix of X, throw "not found".
+5. Otherwise, resolve the remainder of X relative to this package as if it
was loaded via `LOAD_NODE_MODULES` with a name in `package.json`.
```