From 085b12ce8cefabaadb184da710de6e9eafd1497c Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 5 Sep 2021 12:08:37 +0200 Subject: [PATCH] vm: add support for import assertions in dynamic imports --- doc/api/vm.md | 46 +++++++++++++++++++ lib/internal/process/esm_loader.js | 10 +++- lib/vm.js | 2 +- src/module_wrap.cc | 11 +++++ .../parallel/test-vm-module-dynamic-import.js | 16 ++++++- 5 files changed, 81 insertions(+), 4 deletions(-) diff --git a/doc/api/vm.md b/doc/api/vm.md index b7cde0e3b69381..7a8dc946b1c824 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -54,6 +54,10 @@ executed in specific contexts. * `code` {string} JavaScript Module code to parse * `options` @@ -667,6 +681,9 @@ defined in the ECMAScript specification. `import()` will reject with [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`][]. * `specifier` {string} specifier passed to `import()` * `module` {vm.Module} + * `importAssertions` {Object} The `"assert"` value passed to the + [`optionsExpression`][] optional parameter, or an empty object if no value + was provided. * Returns: {Module Namespace Object|vm.Module} Returning a `vm.Module` is recommended in order to take advantage of error tracking, and to avoid issues with namespaces that contain `then` function exports. @@ -852,6 +869,10 @@ const vm = require('vm');