Skip to content

Commit 82ff12a

Browse files
committed
switch to curly braces
Closes #5
1 parent d8be192 commit 82ff12a

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The ImportDeclaration would allow any arbitrary attributes after the `with` keyw
5151
For example, the `type` attribute indicates a module type, and can be used to load JSON modules with the following syntax.
5252

5353
```mjs
54-
import json from "./foo.json" with type: "json";
54+
import json from "./foo.json" with { type: "json" };
5555
```
5656

5757
### dynamic import()
@@ -94,13 +94,13 @@ In the context of the [WebAssembly/ESM integration proposal](https://github.com/
9494

9595
### JSON modules
9696

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.
9898

9999
JSON modules' semantics are those of a single default export which is the entire parsed JSON document.
100100

101101
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.
102102

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.
104104

105105
### Import attributes
106106

@@ -190,26 +190,22 @@ We want to on core questions of this proposal as a Stage 2 prerequisite, includi
190190
// Not selected
191191
import value from "module" as "json";
192192

193-
// Current proposal, to settle on before Stage 2
193+
// Not selected
194194
import value from "module" with type: "json";
195+
196+
// Current proposal, to settle on before Stage 3
197+
import value from "module" with { type: "json" };
195198
```
196199

197200
#### Before stage 3
198201

199202
After Stage 2 and before Stage 3, we're open to settling on some less core details, such as:
200203

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-
import value from "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))
209205

210206
```mjs
211-
import value from "module" when type: 'json';
212-
import value from "module" given type: 'json';
207+
import value from "module" when { type: 'json' };
208+
import value from "module" given { type: 'json' };
213209
```
214210

215211
- How dynamic import would accept import attributes: e.g., with or without an extra level of nesting

spec.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1>Syntax</h1>
2828
<ins>`export` ExportFromClause FromClause WithClause `;`</ins>
2929

3030
WithClause :
31-
<ins>`with` WithEntries</ins>
31+
<ins>`with` `{` WithEntries `}` `;`</ins>
3232

3333
WithEntries :
3434
<ins>IdentifierName `:` StringLiteral</ins>

0 commit comments

Comments
 (0)