@@ -80,15 +80,29 @@ isBuiltin('fs'); // true
80
80
isBuiltin (' wss' ); // false
81
81
` ` `
82
82
83
- ### ` module .register ()`
83
+ ### ` module .register (specifier[, parentURL][, options] )`
84
84
85
85
<!-- YAML
86
86
added: v20.6.0
87
87
-->
88
88
89
- In addition to using the ` -- experimental- loader` option in the CLI,
90
- loaders can be registered programmatically using the
91
- ` module .register ()` method.
89
+ > Stability: 1.1 - Active development
90
+
91
+ * ` specifier` {string} Customization hooks to be registered; this should be the
92
+ same string that would be passed to ` import ()` , except that if it is relative,
93
+ it is resolved relative to ` parentURL` .
94
+ * ` parentURL` {string} If you want to resolve ` specifier` relative to a base
95
+ URL, such as ` import .meta.url` , you can pass that URL here. **Default:**
96
+ ` ' data:' `
97
+ * ` options` {Object}
98
+ * ` data` {any} Any arbitrary, cloneable JavaScript value to pass into the
99
+ [` initialize` ][] hook.
100
+ * ` transferList` {Object\[ ]} [transferrable objects][] to be passed into the
101
+ ` initialize` hook.
102
+ * Returns: {any} returns whatever was returned by the ` initialize` hook.
103
+
104
+ Register a module that exports hooks that customize Node.js module resolution
105
+ and loading behavior.
92
106
93
107
` ` ` mjs
94
108
import { register } from ' node:module' ;
@@ -390,3 +404,4 @@ returned object contains the following keys:
390
404
[` module ` ]: modules.md#the-module-object
391
405
[module wrapper]: modules.md#the-module-wrapper
392
406
[source map include directives]: https://sourcemaps.info/spec.html#h.lmz475t4mvbx
407
+ [transferrable objects]: worker_threads.md#portpostmessagevalue-transferlist
0 commit comments