From 06646e11bec48e53deadb8e99152794bfd724c60 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 12 Dec 2023 19:26:04 +0100 Subject: [PATCH] vm: use import attributes instead of import assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old import assertions proposal has been renamed to "import attributes" with the following major changes: 1. The keyword is now `with` instead of `assert`. 2. Unknown assertions cause an error rather than being ignored. This PR updates the documentation to encourage folks to use the new syntax, and add aliases to preserve backward compatibility. PR-URL: https://github.com/nodejs/node/pull/50141 Backport-PR-URL: https://github.com/nodejs/node/pull/51136 Reviewed-By: Geoffrey Booth Reviewed-By: Vinícius Lourenço Claro Cardoso --- doc/api/vm.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api/vm.md b/doc/api/vm.md index a8ba0903ad6d68..e5cb2ad29ad3cf 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -103,7 +103,7 @@ changes: [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG`][]. * `specifier` {string} specifier passed to `import()` * `script` {vm.Script} - * `importAttributes` {Object} The `"assert"` value passed to the + * `importAttributes` {Object} The `"with"` 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 @@ -635,7 +635,7 @@ changes: * `extra` {Object} * `attributes` {Object} The data from the attribute: ```mjs - import foo from 'foo' assert { name: 'value' }; + import foo from 'foo' with { name: 'value' }; // ^^^^^^^^^^^^^^^^^ the attribute ``` Per ECMA-262, hosts are expected to trigger an error if an @@ -1032,7 +1032,7 @@ changes: [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG`][]. * `specifier` {string} specifier passed to `import()` * `function` {Function} - * `importAttributes` {Object} The `"assert"` value passed to the + * `importAttributes` {Object} The `"with"` 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 @@ -1258,7 +1258,7 @@ changes: [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG`][]. * `specifier` {string} specifier passed to `import()` * `script` {vm.Script} - * `importAttributes` {Object} The `"assert"` value passed to the + * `importAttributes` {Object} The `"with"` 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 @@ -1359,7 +1359,7 @@ changes: [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG`][]. * `specifier` {string} specifier passed to `import()` * `script` {vm.Script} - * `importAttributes` {Object} The `"assert"` value passed to the + * `importAttributes` {Object} The `"with"` 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 @@ -1441,7 +1441,7 @@ changes: [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG`][]. * `specifier` {string} specifier passed to `import()` * `script` {vm.Script} - * `importAttributes` {Object} The `"assert"` value passed to the + * `importAttributes` {Object} The `"with"` 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