module.register(specifier[, parentURL][, options])


稳定性: 1.2 - 发布候选

¥Stability: 1.2 - Release candidate

  • specifier <string> | <URL> 需要注册的定制钩子;这应该与传递给 import() 的字符串相同,但如果它是相对的,则它是相对于 parentURL 解析的。

    ¥specifier <string> | <URL> 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 parentURL.

  • parentURL <string> | <URL> 如果你想要相对于基本 URL(例如 import.meta.url)解析 specifier,你可以在此处传递该 URL。默认值:'data:'

    ¥parentURL <string> | <URL> If you want to resolve specifier relative to a base URL, such as import.meta.url, you can pass that URL here. Default: 'data:'

  • options <Object>

    • parentURL <string> | <URL> 如果你想要相对于基本 URL(例如 import.meta.url)解析 specifier,你可以在此处传递该 URL。如果 parentURL 作为第二个参数提供,则忽略此属性。默认值:'data:'

      ¥parentURL <string> | <URL> If you want to resolve specifier relative to a base URL, such as import.meta.url, you can pass that URL here. This property is ignored if the parentURL is supplied as the second argument. Default: 'data:'

    • data <any> 传递到 initialize 钩子的任何任意的、可克隆的 JavaScript 值。

      ¥data <any> Any arbitrary, cloneable JavaScript value to pass into the initialize hook.

    • transferList <Object[]> 可转换对象 要传递到 initialize 钩子中。

      ¥transferList <Object[]> transferrable objects to be passed into the initialize hook.

注册一个导出 钩子 的模块,用于自定义 Node.js 模块解析和加载行为。参见 定制钩子

¥Register a module that exports hooks that customize Node.js module resolution and loading behavior. See Customization hooks.

如果与 权限模型 一起使用,此功能需要 --allow-worker

¥This feature requires --allow-worker if used with the Permission Model.