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
Copy file name to clipboardExpand all lines: README.md
+10-14Lines changed: 10 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ The ImportDeclaration would allow any arbitrary attributes after the `with` keyw
51
51
For example, the `type` attribute indicates a module type, and can be used to load JSON modules with the following syntax.
52
52
53
53
```mjs
54
-
importjsonfrom"./foo.json" with type: "json";
54
+
importjsonfrom"./foo.json" with { type: "json" };
55
55
```
56
56
57
57
### dynamic import()
@@ -94,13 +94,13 @@ In the context of the [WebAssembly/ESM integration proposal](https://github.com/
94
94
95
95
### JSON modules
96
96
97
-
JSON modules are required to be supported when invoked using the `with type: "json"` syntax, with common semantics in all JavaScript implementations for this syntax.
97
+
JSON modules are required to be supported when invoked using the `with { type: "json" }` syntax, with common semantics in all JavaScript implementations for this syntax.
98
98
99
99
JSON modules' semantics are those of a single default export which is the entire parsed JSON document.
100
100
101
101
Each JavaScript host is expected to provide a secondary way of checking whether a module is a JSON module. For example, on the Web, the MIME type would be checked to be a JSON MIME type. In "local" desktop/server/embedded environments, the file extension may be checked (possibly after symlinks are followed). The `type: "json"` is indicated at the import site, rather than *only* through that other mechanism in order to prevent the privilege escalation issue noted in the opening section.
102
102
103
-
Nevertheless, the interpretation of module loads with no attributes remains host/implementation-defined, so it is valid to implement JSON modules without *requiring*`with type: "json"`. It's just that `with type: "json"` must be supported everywhere. For example, it will be up to Node.js, not TC39, to decide whether import attributes are required or optional for JSON modules.
103
+
Nevertheless, the interpretation of module loads with no attributes remains host/implementation-defined, so it is valid to implement JSON modules without *requiring*`with { type: "json" }`. It's just that `with { type: "json" }` must be supported everywhere. For example, it will be up to Node.js, not TC39, to decide whether import attributes are required or optional for JSON modules.
104
104
105
105
### Import attributes
106
106
@@ -190,26 +190,22 @@ We want to on core questions of this proposal as a Stage 2 prerequisite, includi
190
190
// Not selected
191
191
importvaluefrom"module" as "json";
192
192
193
-
//Current proposal, to settle on before Stage 2
193
+
//Not selected
194
194
importvaluefrom"module" with type: "json";
195
+
196
+
// Current proposal, to settle on before Stage 3
197
+
importvaluefrom"module" with { type: "json" };
195
198
```
196
199
197
200
#### Before stage 3
198
201
199
202
After Stage 2 and before Stage 3, we're open to settling on some less core details, such as:
200
203
201
-
- Decide on the exact syntax of the module import attributes
202
-
203
-
Whether there are curly brackets around import attributes, like an object literal ([#5](https://github.com/tc39/proposal-module-attributes/issues/5))
204
-
```mjs
205
-
importvaluefrom"module" with { type: "json" };
206
-
```
207
-
208
-
Considering alternatives for the `with` keyword ([#3](https://github.com/tc39/proposal-module-attributes/issues/3))
204
+
- Considering alternatives for the `with` keyword ([#3](https://github.com/tc39/proposal-module-attributes/issues/3))
209
205
210
206
```mjs
211
-
importvaluefrom"module" when type: 'json';
212
-
importvaluefrom"module" given type: 'json';
207
+
importvaluefrom"module" when { type: 'json' };
208
+
importvaluefrom"module" given { type: 'json' };
213
209
```
214
210
215
211
- How dynamic import would accept import attributes: e.g., with or without an extra level of nesting
0 commit comments