-
Notifications
You must be signed in to change notification settings - Fork 67
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
feat: add module declaration support #528
Conversation
bf09402
to
ce0ef0e
Compare
@guybedford updated to |
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.
This looks like a great start, thanks.
I'm okay for us to land this as experimental to start even if it's not completely comprehensive. But I'm still wondering if there are other cases we should test though, perhaps some multi-import / multi-interface / resource generation or WASI worlds or otherwise?
Hey @lachieh thanks for contributing this -- I guess this is for both you and @guybedford at the same time but what do y'all think about having a more explicit name for the feature? I can think of at least two ways this would work -- removing the namespace and exporting a module "instead" of namespaces. So concretely something like Also, I was really hoping that this would turn into the default over time as we know it's not likely to break people/works with most things. The ease of use is dramatically better "out of the box" when exporting the module instead of the namespace for guests. I'm happy to help add tests in a follow up (along with some more examples that need to be added to |
This aligns with the experience I detailed in the issue thread. As far as I understand it, the types now are used mostly used for transpiling. I haven't read that code yet so forgive if this is not the right question; would switching to namespaces affect how transpiling works? Should module declarations for guest components be a net-new feature? |
We discussed this in the meeting today - and if there may be potential for wanting to configure whether to use module declarations or namespaces within guest generation then I think this should be guest-specific ie This does have me thinking though - since the flag options may end up being specific to the host or guest path, it might even be worth considering treating this as a new top-level command - |
A bit late responding here but yeah this actually does seem like a good idea... BUT with the documentation burden it would cause... maybe we hold of on that for now :) |
@guybedford I'm in agreement there. Since the behavior of Spoke with @vados-cosmonic today and found a couple of reasons we may indeed want to split the command into a new one, though it will require a bit more discussion—mostly around what you envision the JS/TS experience look like long term. I'm synthesizing some notes on that and will likely post a couple of issues. Are we able to get this one in as is to get some feedback and then continue the discussion on the next phase? |
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.
Thanks for your patience, will aim to land this this week - just wondering if we should switch over to a new command here or in a follow up?
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 realise we skipped over the discussion on this one this morning - please do let me know if there is more to discuss here.
Marking as request changes for now based on the agreement on using the jco guest-types
command name, and not to miss that for review further. Happy to discuss alternatives as well.
Thanks, @guybedford! Not a worry—not much to discuss. I'll get this updated to the new command tomorrow, most likely. |
b582917
to
51cb640
Compare
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.
This is a great start, thank you.
In the main README we usually keep the CLI information up to date in https://github.com/bytecodealliance/jco?tab=readme-ov-file#cli (pending better docs here).
Just would be good to have an experimental note while this feature is not yet stable.
Adds a
jco guest-types
command to output module definitions to be used when implementing guest components.For example, the types for
wasi:http/incoming-handler
are output like thiswhich means that you can import get IDE suggestions for
Closes #439