You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
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 number
Diff line number
Diff line change
@@ -128,10 +128,18 @@ argument to the resolver for easy compatibility workflows.
128
128
129
129
In addition to returning the resolved file URL value, the resolve hook also
130
130
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:
133
132
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
135
143
rules with only JS file extension and Node builtin modules support could
136
144
be written:
137
145
@@ -205,3 +213,5 @@ then be called at the exact point of module evalutation order for that module
205
213
in the import tree.
206
214
207
215
[Node.js EP for ES Modules]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md
0 commit comments