diff --git a/README.md b/README.md index d39995b..125f9c1 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ The ImportDeclaration would allow any arbitrary attributes after the `with` keyw For example, the `type` attribute indicates a module type, and can be used to load JSON modules with the following syntax. ```mjs -import json from "./foo.json" with type: "json"; +import json from "./foo.json" with { type: "json" }; ``` ### dynamic import() @@ -94,13 +94,13 @@ In the context of the [WebAssembly/ESM integration proposal](https://github.com/ ### JSON modules -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. +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. JSON modules' semantics are those of a single default export which is the entire parsed JSON document. 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. -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. +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. ### Import attributes @@ -190,26 +190,22 @@ We want to on core questions of this proposal as a Stage 2 prerequisite, includi // Not selected import value from "module" as "json"; -// Current proposal, to settle on before Stage 2 +// Not selected import value from "module" with type: "json"; + +// Current proposal, to settle on before Stage 3 +import value from "module" with { type: "json" }; ``` #### Before stage 3 After Stage 2 and before Stage 3, we're open to settling on some less core details, such as: -- Decide on the exact syntax of the module import attributes - -Whether there are curly brackets around import attributes, like an object literal ([#5](https://github.com/tc39/proposal-module-attributes/issues/5)) -```mjs -import value from "module" with { type: "json" }; -``` - -Considering alternatives for the `with` keyword ([#3](https://github.com/tc39/proposal-module-attributes/issues/3)) +- Considering alternatives for the `with` keyword ([#3](https://github.com/tc39/proposal-module-attributes/issues/3)) ```mjs -import value from "module" when type: 'json'; -import value from "module" given type: 'json'; +import value from "module" when { type: 'json' }; +import value from "module" given { type: 'json' }; ``` - How dynamic import would accept import attributes: e.g., with or without an extra level of nesting diff --git a/spec.html b/spec.html index f43d45f..655440e 100644 --- a/spec.html +++ b/spec.html @@ -28,7 +28,7 @@

Syntax

`export` ExportFromClause FromClause WithClause `;` WithClause : - `with` WithEntries + `with` `{` WithEntries `}` `;` WithEntries : IdentifierName `:` StringLiteral