From e93d419d40fe9e02240db191b27ed4023c9baa00 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Tue, 15 May 2018 19:09:22 -0500 Subject: [PATCH] add vm.Module linker hook to hookContext --- doc/api/esm.md | 5 +++++ doc/api/vm.md | 3 +++ lib/internal/modules/esm/loader.js | 5 +++++ lib/internal/vm/module.js | 15 +++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/doc/api/esm.md b/doc/api/esm.md index be47ca1371ccd2..b587c233cf3785 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -157,6 +157,9 @@ A hook context consists of the following properties: useful if resolve is not hooked. - `specifier` {string} The specifier of the module to import. - `parentURL` {string} The URL of the module that requested the specifier. +- `vmModuleLinkHook` {object} This value can be passed to [`module.link`][] to + allow linking the import requests of a [`vm.Module`][] instance to the + loader. ### Resolve hook @@ -269,6 +272,8 @@ With the list of module exports provided upfront, the `execute` function will then be called at the exact point of module evaluation order for that module in the import tree. +[`module.link`]: vm.html#vm_module_link_linker +[`vm.Module`]: vm.html#vm_class_vm_module [Node.js EP for ES Modules]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md [addons]: addons.html [dynamic instantiate hook]: #esm_dynamic_instantiate_hook diff --git a/doc/api/vm.md b/doc/api/vm.md index cc9b3135381dad..f434f457c7bb20 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -395,6 +395,8 @@ that point all modules would have been fully linked already, the [HostResolveImportedModule][] implementation is fully synchronous per specification. +The linker may also be passed from [`hookContext.vmModuleLinkhook`][]. + ## Class: vm.Script