Stream: wasi

Topic: Component Model common export


view this post on Zulip Jan Vanhoof (Jun 06 2025 at 09:00):

Hi!
Is there a way to expose one interface to multiple components?

Assume for example that you have a composed component and each component needs to do some logging. Is it possible for the host to provide this logging Interface for all these interfaces, or should each component you plug in to reexport the logging interface it imported from it's predecessor.
As an alternative I think you could also export multiple identical interfaces on the host, one for each component that needs it.

Any thoughts?

It is related to the issue/info request I just created for the documentation. Cargo component will automatically import the necessary WASI interfaces it requires, but can you also easily re-export some of those interfaces? It's not that you mentioned them in your own WIT. And I also assume you will need to do some plumbing to get the export connected to the import.
So in short, main component needs WASI interfaces, not an issue, the runtime will provide the interfaces, but if a depending component also needs to use WASI interfaces, what do you need to do then.

Thanks in advance for some feedback.
Jan

The Documentation mentions that By default, cargo-component imports any required WASI interfaces for us without needing to explicitly declare them. Is there any documentation when this exactly happ...

view this post on Zulip Lann Martin (Jun 06 2025 at 14:14):

The outermost component has to import (and pass through) any host interfaces required by any other component in the composition.

You might be interested in the wac tool. Its DSL provides a lot of flexibility in composing but there is also wac plug which just sort of "does what you want" in many simple scenarios, including what you describe for logging.

WebAssembly Composition (WAC) tooling. Contribute to bytecodealliance/wac development by creating an account on GitHub.

view this post on Zulip Lann Martin (Jun 06 2025 at 14:19):

This is documented in more detail here: https://component-model.bytecodealliance.org/creating-and-consuming/composing.html

view this post on Zulip Notification Bot (Jun 10 2025 at 14:47):

Jan Vanhoof has marked this topic as unresolved.

view this post on Zulip Jan Vanhoof (Jun 10 2025 at 14:58):

I thought this solved it, but I just made it happen.

I have 2 components, both importing a "logging" interface (and not exporting it). Component B only has a "run" function and component A also has the "run" function and just calls the run function on component B.
Host --> run --> compontent A --> run --> component B.

If I compose these ( WAC plug) I get a composed component with only one import "logging" and both of them are able to use it.

But with the wasmbuilder.app I was unable to link 2 components to the same export interface.
Has this something to do with how WAC resolves dangling imports?

Is there a tool that let's you visualize composed WebAssembly components? I tried the wasmbuilder.app as well, but it seems to only show the imports / exports of the composed component itself. Not the interal bindings between the components.

view this post on Zulip Ralph (Jun 17 2025 at 09:31):

not to my knowledge, though there's an obvious tool to be written there. Likely wasmtools component should have a --dump-inner-structure or something


Last updated: Dec 06 2025 at 06:05 UTC