@Peter Huene Do you know why wasm-tools compose
doesn't support composing a component that has a top-level function import? Is this just because it hasn't been added yet or am I missing something more fundamental? My expectation would be that at the very least if I try to composed a component with a function import with an adapter that if the adapter doesn't have a function export that fits the composed component which just continue to import that function.
(I should have posted this in #wasm - if anyone with permissions is able to move it there that would be great)
The CLI was written at a time when only instances were imported and exported, so it simply isn't implemented yet. A workaround is to use wasmbuilder.app and manually connect things, as that can connect functions.
I'm working on a replacement to wasm-compose that will be more flexible and registry-aware.
Happy to help with this - I'm working on a tool that would allow for iterative composition of components, and thus I need programmatic use of the compose library.
@Peter Huene would it be possible to be able to do composition from components in memory instead of always needing to do it from a file?
The graph API has https://docs.rs/wasm-compose/latest/wasm_compose/graph/struct.Component.html#method.from_bytes
Ah somehow I missed that. Thanks!
@Peter Huene oh I see now - I've been using the ComponentComposer
API which only accepts a path
yeah, that thing is just a simplistic interface that drives the CLI
CompositionGraph
underpins everything and is what wasmbuilder.app uses directly
When you say you're rewriting wasm-tools compose, are you planning on doing that from the ground up or is the core going to stay the same? I'm just wondering how much time I should put into adding functionality to my tool rather than waiting for the replacement
mostly found the ground-up, but keeping the parts that make sense (such as the composition graph); there's going to be a WIT-like composition language that is quite expressive in terms of composing components together, with built in support for the registry.
// create an instance of the `foo:bar` component and import the needed instantiation arguments into the composition
let bar = new foo:bar { ... }
// create an instance of the `foo:baz` component, passing `bar` as an instantiation argument, importing the rest
let baz = new foo:baz { bar, ... }
// alias the `run` function from instance `baz` and export it from the composition
export baz.run
Not sure if you can do this for your use case... but I was encountering the same thing when bundling transitive registry dependencies, and inlined the components that were being imported... happy to share some of that if it could help you out for the time being.
Last updated: Nov 22 2024 at 17:03 UTC