Closed Randy-Buchholz closed 3 months ago
This is a good topic to discuss, and we're discussing it in some other issues here, such as #24, e.g., https://github.com/tc39/proposal-module-attributes/issues/24#issuecomment-627096878. Ultimately, ECMA-262 isn't going to say which headers are sent to the server--this is up to host environments, like HTML. I'm proposing that we come to a good conclusion on how some of those environments would work before Stage 3, but ultimately, that we will leave it up to them to make these calls. What do you think?
I'm generally of the same mind about which headers should be sent, and that it should be up to the implementers since in the simplest form (just adding a "import" header item) it isn't something that would show up in the language proper. But I think if a client is expecting a module it would be good manners to let the server know lol.
What I would propose is that in Section 15.2.2 we add an optional "with" clause:
import ImportClause FromClause [WithClause];
This would provide a standardized hook for implementers, and a node for additional specification.
I'm new to the ECMA-262 language specification world and took a look at the specification. To me it reads much like an abstract design. Is there a corresponding "requirements" document? By that I mean something in a form similar to "The language shall...", The language may...". That would be a place to put "recommendations" on what to do with the WithClause.
The standardized hook for implementers to provide their header is called HostResolveImportedModule . It's where the fetching happens, and the module attributes are passed to it.
To help reach a decision we opened a discussion against the HTML spec https://github.com/whatwg/html/issues/5640.
This is done
I have a related item on the WICG Discourse. https://discourse.wicg.io/t/proposal-module-import-headers/4467/1
I'm proposing adding headers to the request when the request is for a module. This helps when building handlers on the request pipeline on the server. Though not directly related, this seems to be a case whose implementation could benfit from headers specific to modules.