Skip to content

Commit

Permalink
mutable JSON module
Browse files Browse the repository at this point in the history
  • Loading branch information
xtuc committed Jun 23, 2020
1 parent d32f315 commit f051178
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ In the context of the [WebAssembly/ESM integration proposal](https://github.com/
JSON modules are required to be supported when invoked using the `if { 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.
The imported object should be mutable and a single instance should exist per Realm [#54](https://github.com/tc39/proposal-import-attributes/issues/54).

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.

Expand Down
4 changes: 4 additions & 0 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ <h1>Runtime Semantics: HostResolveImportedModule ( _referencingScriptOrModule_,
<emu-note type=editor>
<p>The above text implies that hosts *must* support JSON modules imported with `type: "json"` (if it completes normally), but it doesn't prohibit hosts from supporting JSON modules imported with no type specified. Some environments (for example, web browsers) are expected to require `if { type: "json" }`, and environments which want to restrict themselves to a compatible subset would do so as well.</p>
</emu-note>

<emu-note type=editor>
<p>The imported object should be mutable and a single instance should exist per Realm.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-hostimportmoduledynamically" aoid="HostImportModuleDynamically">
Expand Down

0 comments on commit f051178

Please sign in to comment.