esm: use import attributes instead of import assertions

The old import assertions proposal has been
renamed to "import attributes" with the follwing major changes:

1. The keyword is now `with` instead of `assert`.
2. Unknown assertions cause an error rather than being ignored,

This commit updates the documentation to encourage folks to use the new
syntax, and add aliases for module customization hooks.

PR-URL: https://github.com/nodejs/node/pull/50140
Fixes: https://github.com/nodejs/node/issues/50134
Refs: https://github.com/v8/v8/commit/159c82c5e6392e78b9bba7161b1bed6e23758984
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
Antoine du Hamel authored and GitHub committed 2023-10-14 03:52:38 +00:00
1 parent f447a4611a
commit d1ef6aa2db
60 files changed
+470 -351

No files matched your search

+14 -3
View File
@@ -1759,7 +1759,8 @@ added:
- v16.14.0
-->
An import assertion has failed, preventing the specified module to be imported.
An import `type` attribute was provided, but the specified module is of a
different type.
<a id="ERR_IMPORT_ASSERTION_TYPE_MISSING"></a>
@@ -1771,7 +1772,7 @@ added:
- v16.14.0
-->
An import assertion is missing, preventing the specified module to be imported.
An import attribute is missing, preventing the specified module to be imported.
<a id="ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED"></a>
@@ -1783,7 +1784,17 @@ added:
- v16.14.0
-->
An import assertion is not supported by this version of Node.js.
An import attribute is not supported by this version of Node.js.
<a id="ERR_IMPORT_ATTRIBUTE_UNSUPPORTED"></a>
### `ERR_IMPORT_ATTRIBUTE_UNSUPPORTED`
<!-- YAML
added: REPLACEME
-->
An import attribute is not supported by this version of Node.js.
<a id="ERR_INCOMPATIBLE_OPTION_PAIR"></a>