Skip to content

Commit

Permalink
module: add docs signature for register
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyBooth committed Aug 20, 2023
1 parent 41a3a1d commit 80a1649
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions doc/api/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,27 @@ isBuiltin('fs'); // true
isBuiltin('wss'); // false
```
### `module.register()`
### `module.register(specifier[, parentURL[, options]])`
<!-- YAML
added: REPLACEME
added: v20.6.0
-->
In addition to using the `--experimental-loader` option in the CLI,
loaders can be registered programmatically using the
`module.register()` method.
* `specifier` {string} customization hooks to be registered; this should be the
same string that would be passed to `import()`, except that if it is relative,
it is resolved relative to `process.cwd()`
* `parentURL` {string} if you want to resolve `specifier` relative to a
different base than `process.cwd()`, such as `import.meta.url`, you can pass
that URL here
* `options` {Object}
* `data` {any} Any arbitrary, cloneable JavaScript value to pass into the
[`initialize`][] hook
* `transferList` {Object\[]} \[transferrable objects]\[] to be passed into the
`initialize` hook
* Returns: {any} returns whatever was returned by the `initialize` hook
Register a module that exports hooks that customize Node.js’ module resolution
and loading behavior.
```mjs
import { register } from 'node:module';
Expand Down

0 comments on commit 80a1649

Please sign in to comment.