DEP0205: module.register()


类型:仅文档

🌐 Type: Documentation-only

module.register() 已被弃用。请改用 module.registerHooks()

module.register() API 提供了用于自定义 ES 模块的线程外异步钩子;module.registerHooks() API 提供了类似的钩子,它们是同步的、线程内的,并且适用于所有类型的模块。支持异步钩子被证明是复杂的,涉及到工作线程的调度,并且存在一些已被证明无法解决的问题。参见 异步自定义钩子的注意事项。请尽快迁移到 module.registerHooks(),因为 module.register() 将在未来的 Node.js 版本中被移除。

🌐 The module.register() API provides off-thread async hooks for customizing ES modules; the module.registerHooks() API provides similar hooks that are synchronous, in-thread, and work for all types of modules. Supporting async hooks has proven to be complex, involving worker threads orchestration, and there are issues that have proven unresolvable. See caveats of asynchronous customization hooks. Please migrate to module.registerHooks() as soon as possible as module.register() will be removed in a future version of Node.js.