-
Notifications
You must be signed in to change notification settings - Fork 32
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
Support for targeting multiple worlds #100
Comments
@karthik2804 interesting use case. Is there a way to upstream the work done for componentize-py here in a way that can be shared? Alternatively I'd be open to a PR in these directions. |
I can't think of a way to make the multi-world support reusable outside of A couple of things to note based on the
|
We already use It sounds like this is just another set of merge calls, and everything should work out since merge will combined same-named worlds already. The bindgen for Jco works against a resolve object and a world, so if the final resolve object has all the merges, and the final world includes all the other worlds, it sounds like the bindgen should just work out to me as all the deduplication is otherwise already done at the other levels. I don't mean to over-simplify, but am I missing anything here? |
What For example, a developer might use the spin-sdk and target one of its worlds, e.g. |
@dicej thanks for explaining the use case better here, it sounds like they targeting different sets of exported interfaces in this case. If I'm understanding right, we would then target multiple JS source files specifying That does not seem unviable to support within the scope of ComponentizeJS to me. |
@guybedford revisiting this issue. I am a little confused by the following statement.
We could also have a single source file that has imports from multiple worlds correct? Something along the lines of
The guest code could target both the worlds and look like something below import { initialCwd } from "wasi:cli/[email protected]"
export const incomingHandler = {
handle: () => {
console.log(initialCwd())
}
} |
@karthik2804 it would help to understand the use case for merging in this scenario. Of course it is possible, I was just fitting a direct source - world model which would effectively only gate the allowed imports per world. A merging semantic could also be designed of course, although there are likely other edge cases then too. |
@guybedford A more concrete example would be the case of building an SDK for Spin that supports only the HTTP trigger. Since spin supports adding other types of triggers through plugins, it would be nice to be able to add support for them through other SDK packages. In the ideal scenario, the base SDK package (call it |
@karthik2804 yes we can just merge the worlds together then, and implement them all from one top-level JS file. Something like: export const cronTrigger = {
// ... cron trigger world
}
export const sqsTrigger = {
// ...sqs trigger world
} Or alternatively via: export * as cronTrigger from './cron.js';
export * as sqsTrigger from './sqs.js'; And we can even support multi version as per the I was under the impression that the feature required here was the ability to author separate JS files targeting separate worlds like componentize-py, but the above would fit much more simply into the ComponentizeJS model anyway? |
The important distinction about how For example, I can say
This allows packages like I realize this is a bit complicated and subtle, so happy to elaborate if it's still not clear. The main takeaway is that |
If you're looking to publish If so, then perhaps we can arrange to discuss further around what has been considered here for Jco and how that could fit into a ComponentizeJS workflow here? |
Would it make sense to discuss this at the next Jco meeting? @karthik2804 and @tschneidereit would you be able to make it on July 15 at 5pm UTC? I'm not sure myself what the plan is for a JS Spin SDK and how it will compare to the Python one. |
I'd be happy to discuss this at the next meeting. |
I will be able to make the Jco meeting. |
It would be great to support the ability to create a component that can target the union of multiple worlds in the cases where the user cannot edit the wit file to create a third world that includes the target worlds. An example of this would be an SDK built on top of a wit that bundles the wit in an npm package and the user application wanting to target their world where there would be 2 distinct
wit
folders.This request is motivated by the ability to do that in
componentize-py
(the commit that added the support).The text was updated successfully, but these errors were encountered: