| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e1c6f46 commit 258df0e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1722,14 +1722,14 @@ success! | |||
| 1722 | 1722 | [`import`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import | |
| 1723 | 1723 | [`initialize`]: #initialize | |
| 1724 | 1724 | [`module.createRequire()`]: module.md#modulecreaterequirefilename | |
| 1725 | - [`module.register()`]: module.md#moduleregister | ||
| 1725 | + [`module.register()`]: module.md#moduleregisterspecifier-parenturl-options | ||
| 1726 | 1726 | [`module.syncBuiltinESMExports()`]: module.md#modulesyncbuiltinesmexports | |
| 1727 | 1727 | [`package.json`]: packages.md#nodejs-packagejson-field-definitions | |
| 1728 | 1728 | [`port.postMessage`]: worker_threads.md#portpostmessagevalue-transferlist | |
| 1729 | 1729 | [`port.ref()`]: https://nodejs.org/dist/latest-v17.x/docs/api/worker_threads.html#portref | |
| 1730 | 1730 | [`port.unref()`]: https://nodejs.org/dist/latest-v17.x/docs/api/worker_threads.html#portunref | |
| 1731 | 1731 | [`process.dlopen`]: process.md#processdlopenmodule-filename-flags | |
| 1732 | - [`register`]: module.md#moduleregister | ||
| 1732 | + [`register`]: module.md#moduleregisterspecifier-parenturl-options | ||
| 1733 | 1733 | [`string`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String | |
| 1734 | 1734 | [`util.TextDecoder`]: util.md#class-utiltextdecoder | |
| 1735 | 1735 | [cjs-module-lexer]: https://github.com/nodejs/cjs-module-lexer/tree/1.2.2 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,15 +78,29 @@ isBuiltin('fs'); // true | |||
| 78 | 78 | isBuiltin('wss'); // false | |
| 79 | 79 | ``` | |
| 80 | 80 | ||
| 81 | - ### `module.register()` | ||
| 81 | + ### `module.register(specifier[, parentURL][, options])` | ||
| 82 | 82 | ||
| 83 | 83 | <!-- YAML | |
| 84 | 84 | added: REPLACEME | |
| 85 | 85 | --> | |
| 86 | 86 | ||
| 87 | - In addition to using the `--experimental-loader` option in the CLI, | ||
| 88 | - loaders can be registered programmatically using the | ||
| 89 | - `module.register()` method. | ||
| 87 | + > Stability: 1.1 - Active development | ||
| 88 | + | ||
| 89 | + * `specifier` {string} Customization hooks to be registered; this should be the | ||
| 90 | + same string that would be passed to `import()`, except that if it is relative, | ||
| 91 | + it is resolved relative to `parentURL`. | ||
| 92 | + * `parentURL` {string} If you want to resolve `specifier` relative to a base | ||
| 93 | + URL, such as `import.meta.url`, you can pass that URL here. **Default:** | ||
| 94 | + `'data:'` | ||
| 95 | + * `options` {Object} | ||
| 96 | + * `data` {any} Any arbitrary, cloneable JavaScript value to pass into the | ||
| 97 | + [`initialize`][] hook. | ||
| 98 | + * `transferList` {Object\[]} [transferrable objects][] to be passed into the | ||
| 99 | + `initialize` hook. | ||
| 100 | + * Returns: {any} returns whatever was returned by the `initialize` hook. | ||
| 101 | + | ||
| 102 | + Register a module that exports hooks that customize Node.js module resolution | ||
| 103 | + and loading behavior. | ||
| 90 | 104 | ||
| 91 | 105 | ```mjs | |
| 92 | 106 | import { register } from 'node:module'; | |
@@ -384,3 +398,4 @@ returned object contains the following keys: | |||
| 384 | 398 | [`module`]: modules.md#the-module-object | |
| 385 | 399 | [module wrapper]: modules.md#the-module-wrapper | |
| 386 | 400 | [source map include directives]: https://sourcemaps.info/spec.html#h.lmz475t4mvbx | |
| 401 | + [transferrable objects]: worker_threads.md#portpostmessagevalue-transferlist | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments