Call linker when dynamically importing inside a vm.Module #19363
Labels
esm
Issues and PRs related to the ECMAScript Modules implementation.
feature request
Issues that request new features to be added to Node.js.
vm
Issues and PRs related to the vm subsystem.
Dynamically importing from a Module
Currently
vm.Module
can construct and evaluate modules just fine, but there's no way for one of those modules to dynamically import another file e.g.:Now for dynamic import reusing the linker function should be sufficient as the algorithm for resolving a dynamic module should be the same as for a static module.
Hence we can do
import("some-specifier")
with this simple process:importedModule
belinkerFunction("some-specifier", importingModule)
.importedModule.instantiate()
.importedModule.evaluate()
import("some-specifier")
withimportedModule.namespace
.import("some-specifier")
Dynamically importing from a Script
Because the script goal also supports dynamic import we need a way to be able to create a
vm.Script
with a dynamic import hook, I'm not really sure where this should go, perhaps alinker
option toscript.runInContext(...)
(and variants).For this to be easily compatible with
vm.Module
thenvm.Script
should also support theurl
option in lieu offilename
so that the linker can just inspect the.url
property to perform linking.e.g.:
The text was updated successfully, but these errors were encountered: