You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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: nodejs/node#50140
Backport-PR-URL: nodejs/node#50669Fixes: nodejs/node#50134
Refs: v8/v8@159c82c
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Jacob Smith <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Copy file name to clipboardExpand all lines: graal-nodejs/lib/internal/modules/esm/assert.js
+24-30
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,6 @@
3
3
const{
4
4
ArrayPrototypeFilter,
5
5
ArrayPrototypeIncludes,
6
-
ObjectCreate,
7
6
ObjectKeys,
8
7
ObjectValues,
9
8
ObjectPrototypeHasOwnProperty,
@@ -14,16 +13,15 @@ const {
14
13
ERR_IMPORT_ASSERTION_TYPE_FAILED,
15
14
ERR_IMPORT_ASSERTION_TYPE_MISSING,
16
15
ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED,
16
+
ERR_IMPORT_ATTRIBUTE_UNSUPPORTED,
17
17
}=require('internal/errors').codes;
18
18
19
19
// The HTML spec has an implied default type of `'javascript'`.
20
20
constkImplicitAssertType='javascript';
21
21
22
-
letalreadyWarned=false;
23
-
24
22
/**
25
-
* Define a map of module formats to import assertion types (the value of
26
-
* `type` in `assert { type: 'json' }`).
23
+
* Define a map of module formats to import attributes types (the value of
24
+
* `type` in `with { type: 'json' }`).
27
25
* @type {Map<string, string>}
28
26
*/
29
27
constformatTypeMap={
@@ -32,13 +30,13 @@ const formatTypeMap = {
32
30
'commonjs': kImplicitAssertType,
33
31
'json': 'json',
34
32
'module': kImplicitAssertType,
35
-
'wasm': kImplicitAssertType,// It's unclear whether the HTML spec will require an assertion type or not for Wasm; see https://github.com/WebAssembly/esm-integration/issues/42
33
+
'wasm': kImplicitAssertType,// It's unclear whether the HTML spec will require an attribute type or not for Wasm; see https://github.com/WebAssembly/esm-integration/issues/42
36
34
};
37
35
38
36
/**
39
37
* The HTML spec disallows the default type to be explicitly specified
0 commit comments