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
Copy file name to clipboardExpand all lines: doc/design/overview.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,21 @@
1
1
# Loaders Design
2
2
3
-
There are currently [three loader hooks](https://github.com/nodejs/node/tree/master/doc/api/esm.html#esm_hooks):
3
+
There are currently the following [loader hooks](https://github.com/nodejs/node/tree/master/doc/api/esm.html#esm_hooks):
4
4
5
5
1.`resolve`: Takes a specifier (the string after `from` in an `import` statement) and converts it into an URL to be loaded.
6
6
7
-
1.`loadManifest`: Takes the resolved URL and returns the `package.json` from the location (or `null` if it doesn't exist).
8
-
9
7
1.`load`: Takes the resolved URL and returns runnable code (JavaScript, Wasm, etc.) as well as the name of one of Node’s ESM loader’s [“translators”](https://github.com/nodejs/node/blob/master/lib/internal/modules/esm/translators.js):
10
8
*`commonjs`
11
9
*`module`
12
10
*`builtin` (a Node internal module, like `fs`)
13
11
*`json` (with `--experimental-json-modules`)
14
12
*`wasm` (with `--experimental-wasm-modules`)
15
13
16
-
*`globalPreload`: Defines a string of JavaScript to be injected into the application global scope.
14
+
1.`statFile`: Takes the resolved URL and returns its [`fs.Stats` record](https://nodejs.org/api/fs.html#class-fsstats) (or `null` if it doesn't exist).
15
+
16
+
1.`readFile`: Takes the resolved URL and returns its binary content (or `null` if it doesn't exist).
17
+
18
+
1.`globalPreload`: Defines a string of JavaScript to be injected into the application global scope.
0 commit comments