-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define Web IDL Modules #675
Conversation
A thing I'm missing here is infrastructure around scoping. module X {
interface Y { ... };
};
interface Y { ... }; Is that okay? If not, what forbids it? If it is, what forbids the second interface declaration from being |
I was hoping that this would be OK to have two different interfaces named
If you think full expressiveness here is important, I could update this patch to do that. |
That all sounds good to me, modulo what comes out of #676 but that can be addressed at that point and isn't needed for v1. (I'm not entirely sure what needs changing to clarify scope unfortunately.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial thoughts, mostly editorial, below.
f42cea2
to
a799b27
Compare
@littledan Is there a summary somewhere of what the actual syntax this PR implements is? |
@bzbarsky Added an example in the PR description; is this the level of detail you're looking for? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. Overall LGTM, although maybe we should hold off on merging until we get synthetic module records accepted.
Thinking about the comments on ambiguity from @domenic and @annevk a bit more, I'm thinking that it could be best to switch to a model where you declare a module with an identifier and then refer to interfaces declared within it as The only thing I can see potentially missing is that you can't use It'll be a little while until I have a chance to get back to this; if @Ms2ger or someone else is interested in picking this up, that'd be welcome, or otherwise I will a bit later. |
This is ready for review, btw. |
A couple additional suggestions which @domenic and I recently discussed offline. I think any of these could be follow-ons and don't need to block the PR.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. I think we should add an "under construction" signage, file issues for the other follow-ups @littledan mentioned, and merge. Really nice work.
We can then iterate on those issues and also attempt to use modules in the KV storage spec. I don't think we'll want to merge into KV storage quite yet because of the remaining issues in WICG/kv-storage#46, but just writing the spec patch would give us a good idea of how these things would be used. For example it'd let us see "set a module attribute" in action.
<div algorithm> | ||
[=Interfaces=] and [=partial interfaces=] have a | ||
<dfn for="interface,partial interface">scoped identifier</dfn>, | ||
which uniquely identifies an [=interface=]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a separate concept from qualfiied name? The difference seems to be that for modules we allow two same-named interfaces in different modules, but we don't allow two same-named interfaces in [LegacyNamespace]. Is that mismatch desirable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing how LegacyNamespace works in this PR seems out of scope to me. Note that, if I connected everything correctly, using the qualified name would mean you'd need changes like this to specifications that use it:
namespace WebAssembly {
- Promise<Module> compile(BufferSource bytes);
+ Promise<WebAssembly.Module> compile(BufferSource bytes);
};
Maybe we want that, but let's discuss that separately.
Just want to check that this is not blocked on me at this point. I'm excited to see this land, but I also appreciate how every new commit from @Ms2ger corrects more subtle issues that I totally missed, so I'm happy to wait it out. |
Things that would be nice to see clarified:
|
Wait until someone uses the feature, and then write tests. Possibly https://tc39.github.io/proposal-temporal/ or https://wicg.github.io/kv-storage/ might be the first.
I don't have a clue. Maybe @saschanaz has thoughts on webidl.js. |
I think I'm happy to squash and land this. (At least until the next time I read through the diff.) I'll do that some time next week, if I hear no objections. |
Will happily start to add support when this PR merges. |
I'm a little worried about landing something this big without a downstream user PR and browser implementation commitments. We kinda stopped adding "speculative" things a while ago. And while this isn't completely speculative, it still seems good to work it out end-to-end, no? |
|
||
<pre class="grammar" id="prod-PartialModule"> | ||
PartialModule : | ||
"module" identifier "{" ModuleMembers "}" ";" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have two exactly same grammars Module
and PartialModule
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To distinguish the two cases in the definition of "module declaration" and "partial module declaration". There may be a better way to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following two sentences are ambiguous become the grammars are same:
A module declaration is a definition matching the Module nonterminal symbol.A partial module declaration is a definition matching the PartialModule nonterminal symbol.
Ah okay, actually not, sorry.
I'd be happy to see this land, but could you make a big "work in progress within the draft, do not use yet" at the top? @domenic and I have been talking about whether interfaces should switch into some "new defaults" when inside of a module, which would bring sizable semantics changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
cc @mattijs |
@annevk, are you OK with landing this? Chrome is interested in implementing, and my understanding is that folks like @lukewagner and @tschneidereit were also interested. (@Ms2ger, there are some merge conflicts.) |
Is there a downstream PR? What about the sizeable semantic changes @littledan mentioned? |
I'm unsure what you mean by "downstream"? We indeed might make sizable semantics changes before shipping; those are captured in e.g. #718 and #719. But it's good to make incremental progress, so that specs can use modules at all, before we contemplate exactly what might change by default inside modules. |
I meant a PR for a spec that wants to use this as-is. |
Ah, I'll work on that today. |
For posterity, @Ms2ger notes that he's already started in https://github.com/WICG/kv-storage/compare/master...Ms2ger:idl?expand=1, and in fact the modules part is done there. (It appears that parts that are unfinished are related to #720.) |
I think we should be able to land this after rebasing. WICG/kv-storage#68 is what wants to use this. |
21b767c
to
d2c1dd0
Compare
This PR defines the ability in WebIDL to define JavaScript built-in modules. These semantics set the module map, which makes sense in the context of the import maps draft specification https://wicg.github.io/import-maps/
@annevk ping on whether you're OK to land this. I am going to land WICG/kv-storage#68 today with reference to this pull request, but basing it on the actual IDL spec would be even better. |
For clarity, while Mozilla is supportive of KV Storage, it's still a little unclear what is happening with Builtin Modules (see mozilla/standards-positions#147) which means I'm not comfortable moving forward with this. |
This PR defines the ability in WebIDL to define JavaScript built-in modules.
Modules are defined with a new
module
declaration, which can containregular operations, readonly attributes, and interfaces. For example:
This PR is based on the proposed infrastructure at
tc39/proposal-built-in-modules#44
These semantics set the module map, which makes sense in the context of
the import maps draft specification
https://wicg.github.io/import-maps/
Closes #592
Preview | Diff