From 08ffbd115e5170274f3c0bea602378903fd03173 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 PR-URL: https://github.com/nodejs/node/pull/40249 Reviewed-By: Bradley Farias Reviewed-By: Guy Bedford Reviewed-By: Gus Caplan Reviewed-By: Geoffrey Booth --- doc/api/vm.md | 46 +++++++++++++++++++ lib/internal/process/esm_loader.js | 10 +++- lib/vm.js | 2 +- src/module_wrap.cc | 28 +++++++---- .../parallel/test-vm-module-dynamic-import.js | 16 ++++++- 5 files changed, 90 insertions(+), 12 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');