diff options
author | Lucas Azzola <derflatulator@gmail.com> | 2017-10-22 14:03:18 +1000 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-11-23 14:59:12 +0100 |
commit | e5d4aeb6ac37385e7aaa90020ea786be126a827a (patch) | |
tree | 06a66d1c921c25bc9248e81f42ca721a0f68f2b7 /doc/api/esm.md | |
parent | e46c3f743dc78ef0a614289a874e1c60c7e96490 (diff) | |
download | node-new-e5d4aeb6ac37385e7aaa90020ea786be126a827a.tar.gz |
doc: document resolve hook formats
Add `"dynamic"` to the list of supported `format`s returned by a
custom resolve hook.
Add a table describing the meaning of each `format`.
PR-URL: https://github.com/nodejs/node/pull/16375
Refs: https://github.com/nodejs/node/pull/15445
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Diffstat (limited to 'doc/api/esm.md')
-rw-r--r-- | doc/api/esm.md | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md index c33badf3af..c352c24aa1 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -128,10 +128,18 @@ argument to the resolver for easy compatibility workflows. In addition to returning the resolved file URL value, the resolve hook also returns a `format` property specifying the module format of the resolved -module. This can be one of `"esm"`, `"cjs"`, `"json"`, `"builtin"` or -`"addon"`. +module. This can be one of the following: -For example a dummy loader to load JavaScript restricted to browser resolution +| `format` | Description | +| --- | --- | +| `"esm"` | Load a standard JavaScript module | +| `"cjs"` | Load a node-style CommonJS module | +| `"builtin"` | Load a node builtin CommonJS module | +| `"json"` | Load a JSON file | +| `"addon"` | Load a [C++ Addon][addons] | +| `"dynamic"` | Use a [dynamic instantiate hook][] | + +For example, a dummy loader to load JavaScript restricted to browser resolution rules with only JS file extension and Node builtin modules support could be written: @@ -205,3 +213,5 @@ then be called at the exact point of module evalutation order for that module in the import tree. [Node.js EP for ES Modules]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md +[addons]: addons.html +[dynamic instantiate hook]: #esm_dynamic_instantiate_hook |