Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f4121de

Browse files
committedOct 22, 2017
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`. Refs: #15445
1 parent 8e268c7 commit f4121de

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed
 

‎doc/api/esm.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,18 @@ argument to the resolver for easy compatibility workflows.
129129

130130
In addition to returning the resolved file URL value, the resolve hook also
131131
returns a `format` property specifying the module format of the resolved
132-
module. This can be one of `"esm"`, `"cjs"`, `"json"`, `"builtin"` or
133-
`"addon"`.
132+
module. This can be one of the following:
134133

135-
For example a dummy loader to load JavaScript restricted to browser resolution
134+
| `format` | Description |
135+
| --- | --- |
136+
| `"esm"` | Load a standard JavaScript module |
137+
| `"cjs"` | Load a node-style CommonJS module |
138+
| `"builtin"` | Load a node builtin CommonJS module |
139+
| `"json"` | Load a JSON file |
140+
| `"addon"` | Load a [C++ Addon][addons] |
141+
| `"dynamic"` | Use a [dynamic instantiate hook][] |
142+
143+
For example, a dummy loader to load JavaScript restricted to browser resolution
136144
rules with only JS file extension and Node builtin modules support could
137145
be written:
138146

@@ -206,3 +214,5 @@ then be called at the exact point of module evalutation order for that module
206214
in the import tree.
207215

208216
[Node.js EP for ES Modules]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md
217+
[addons]: addons.html
218+
[dynamic instantiate hook]: #esm_dynamic_instantiate_hook

0 commit comments

Comments
 (0)
Please sign in to comment.