summaryrefslogtreecommitdiff
path: root/doc/api/modules.md
diff options
context:
space:
mode:
authorGuy Bedford <guybedford@gmail.com>2019-08-02 01:30:32 -0400
committerGuy Bedford <guybedford@gmail.com>2019-08-12 06:24:28 -0400
commit2103ae483547831281e1e3882029e37d445689a7 (patch)
tree78199f21a7898ea63ef1e64b85c8f74c6b669171 /doc/api/modules.md
parent15b2d1331082c66adf608bb4de9987aa47a25358 (diff)
downloadandroid-node-v8-2103ae483547831281e1e3882029e37d445689a7.tar.gz
android-node-v8-2103ae483547831281e1e3882029e37d445689a7.tar.bz2
android-node-v8-2103ae483547831281e1e3882029e37d445689a7.zip
module: pkg exports validations and fallbacks
PR-URL: https://github.com/nodejs/node/pull/28949 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
Diffstat (limited to 'doc/api/modules.md')
-rw-r--r--doc/api/modules.md19
1 files changed, 10 insertions, 9 deletions
diff --git a/doc/api/modules.md b/doc/api/modules.md
index bf8209965e..7197ef6ae2 100644
--- a/doc/api/modules.md
+++ b/doc/api/modules.md
@@ -202,11 +202,12 @@ NODE_MODULES_PATHS(START)
5. return DIRS
```
-If `--experimental-exports` is enabled,
-node allows packages loaded via `LOAD_NODE_MODULES` to explicitly declare
-which filepaths to expose and how they should be interpreted.
-This expands on the control packages already had using the `main` field.
-With this feature enabled, the `LOAD_NODE_MODULES` changes as follows:
+If `--experimental-exports` is enabled, Node.js allows packages loaded via
+`LOAD_NODE_MODULES` to explicitly declare which file paths to expose and how
+they should be interpreted. This expands on the control packages already had
+using the `main` field.
+
+With this feature enabled, the `LOAD_NODE_MODULES` changes are:
```txt
LOAD_NODE_MODULES(X, START)
@@ -224,10 +225,10 @@ RESOLVE_BARE_SPECIFIER(DIR, X)
b. If "exports" is null or undefined, GOTO 3.
c. Find the longest key in "exports" that the subpath starts with.
d. If no such key can be found, throw "not found".
- e. If the key matches the subpath entirely, return DIR/name/${exports[key]}.
- f. If either the key or exports[key] do not end with a slash (`/`),
- throw "not found".
- g. Return DIR/name/${exports[key]}${subpath.slice(key.length)}.
+ e. let RESOLVED_URL =
+ PACKAGE_EXPORTS_TARGET_RESOLVE(pathToFileURL(DIR/name), exports[key],
+ subpath.slice(key.length)), as defined in the esm resolver.
+ f. return fileURLToPath(RESOLVED_URL)
3. return DIR/X
```