Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dcab0de

Browse filesBrowse files
azzgibfahn
authored andcommitted
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: #16375 Refs: #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>
1 parent fa6867d commit dcab0de
Copy full SHA for dcab0de

File tree

Expand file treeCollapse file tree

1 file changed

+13
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-3
lines changed
Open diff view settings
Collapse file

‎doc/api/esm.md‎

Copy file name to clipboardExpand all lines: doc/api/esm.md
+13-3Lines changed: 13 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,18 @@ argument to the resolver for easy compatibility workflows.
128128

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

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

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.