Skip to content

Commit dd0c0ea

Browse files
bfarias-godaddylittledan
authored andcommitted
generalize phrasing to avoid specific host preference
1 parent 7ad5417 commit dd0c0ea

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,52 +36,55 @@ This proposal pursues the third option, as we expect it to lead to the best deve
3636

3737
Module attributes have to be made available in several different contexts. This section contains one possible syntax, but there are other options, discussed in [#6](https://github.com/littledan/proposal-module-attributes/issues/6).
3838

39-
Here, a key-value syntax is used, with the key `type` indicating the module type. Such key-value syntax can be used in various different contexts. Another option is to have just a single string (discussion in [#11](https://github.com/littledan/proposal-module-attributes/issues/11)).
39+
Here, a key-value syntax is used, with the key `type` used as an example indicating the module type. Such key-value syntax can be used in various different contexts. Another option is to have just a single string (discussion in [#11](https://github.com/littledan/proposal-module-attributes/issues/11)).
4040

41-
The JavaScript standard would basically be responsible for passing the options bag up to the host environment, which could then decide how to interpret it. Issues [#24](https://github.com/littledan/proposal-module-attributes/issues/24) and [#25](https://github.com/littledan/proposal-module-attributes/issues/25) discuss the Web and Node.js semantics respectively, and issue [#10](https://github.com/littledan/proposal-module-attributes/issues/10) discusses how much we may or may not want to aim for unified behavior across different JavaScript environments.
41+
The JavaScript standard would basically be responsible for passing the options bag up to the host environment, which could then decide how to interpret it. Issues [#24](https://github.com/littledan/proposal-module-attributes/issues/24) and [#25](https://github.com/littledan/proposal-module-attributes/issues/25) discuss the Web and Node.js feature and semantic requirements respectively, and issue [#10](https://github.com/littledan/proposal-module-attributes/issues/10) discusses how to allow different JavaScript environments to have interoperability.
4242

4343
### import statements
4444

4545
The ImportDeclaration would allow any arbitrary attributes after the `with` keyword.
4646

47-
A `type` key should be mandatory to load a module that isn't JavaScript (json, css, html, ...).
47+
For example, in some environments a `type` key could be mandatory to load a module that isn't JavaScript (json, css, html, ...).
4848

4949
```js
5050
import json from "./foo.json" with type: "json";
5151
```
5252

5353
### dynamic import()
5454

55-
The `import` function will allow to provide arbritrary attributes as its second arguments.
55+
The `import` function will allow to provide arbitrary attributes as its second arguments.
5656

5757
```js
5858
import("foo.json", { type: "json" })
5959
```
60+
### Integration Example
6061

61-
### HTML
62+
A host environment may wish to have `type` or similar apply to loading WebAssembly. WebAssembly's validation would fail if the magic number is not correct, but we'd assert that the mimetype matches the type before even before running the WebAssembly validation.
6263

63-
```html
64-
<script src="foo.wasm" type="webassembly"></script>
65-
```
66-
67-
WebAssembly's validation would fail if the magic number is not correct, but we'd assert that the mimetype matches the type before even before running the WebAssembly validation.
64+
Note, this is an example; it's still uncertain whether importing WebAssembly modules would need to be marked specially, or could use `type="module"` just like JavaScript (and no special `with type:` in import statements). Further discussion in [#19](https://github.com/littledan/proposal-module-attributes/issues/19).
6865

69-
Note, it's still uncertain whether importing WebAssembly modules would need to be marked specially, or could use `type="module"` just like JavaScript (and no special `with type:` in import statements). Further discussion in [#19](https://github.com/littledan/proposal-module-attributes/issues/19).
66+
From there, a host environment could integrate with its own APIs or even other languages:
7067

71-
### WebAssembly
72-
73-
For imports of other module types from within a WebAssembly module, this proposal would introduce a new custom section (named `importattributes`) that will annotate with attributes each imported module (which is listed in the import section).
74-
75-
### Worker instantiation
68+
#### Worker instantiation
7669

7770
```js
7871
new Worker("foo.wasm", { type: "webassembly" });
7972
```
8073

74+
#### HTML
75+
76+
```html
77+
<script src="foo.wasm" type="webassembly"></script>
78+
```
79+
80+
#### WebAssembly
81+
82+
For imports of other module types from within a WebAssembly module, this proposal would introduce a new custom section (named `importattributes`) that will annotate with attributes each imported module (which is listed in the import section).
83+
8184
## Status and plan for standardization
8285

8386
This proposal has not yet been presented in a standards body. It's considered Stage 0 in TC39's process because we plan to present it to the committee. The plan is to collect feedback in issues, and present for Stage 1 in the December 2019 TC39 meeting.
8487

85-
Standardization here would consist of building consensus not just in TC39 but also in WHATWG HTML as well as the Node.js ESM effort and a general plan for semantics across various JS environments ([#10](https://github.com/littledan/proposal-module-attributes/issues/10), [#24](https://github.com/littledan/proposal-module-attributes/issues/24) and [#25](https://github.com/littledan/proposal-module-attributes/issues/25)). Stage 2 will also require that we have a strong initial answer for the surface syntax ([#6](https://github.com/littledan/proposal-module-attributes/issues/6)), including the choice of whether we use a single string or key/value pairs ([#12](https://github.com/littledan/proposal-module-attributes/issues/12)).
88+
Standardization here would consist of building consensus not just in TC39 but also in WHATWG HTML as well as the Node.js ESM effort and a general audit of semantic requirements across various host environments ([#10](https://github.com/littledan/proposal-module-attributes/issues/10), [#24](https://github.com/littledan/proposal-module-attributes/issues/24) and [#25](https://github.com/littledan/proposal-module-attributes/issues/25)). Stage 2 will also require that we have a strong initial answer for the surface syntax ([#6](https://github.com/littledan/proposal-module-attributes/issues/6)), including the choice of whether we use a single string or key/value pairs ([#12](https://github.com/littledan/proposal-module-attributes/issues/12)).
8689

8790
Please leave any feedback you have in the [issues](http://github.com/littledan/proposal-module-attributes/issues)!

0 commit comments

Comments
 (0)