Hey! I use WASM as a plugin system. I have a plugin A that provides information. It's existence during runtime is not guaranteed, though. Is it possible to implement "optional" imports using the component model? I.e., have a plugin B check if A is available and if it is, call its functions?
AFAIK, there is no official specification for this feature, but there is interest. In the meantime, can I somehow hook into wasmtime to provide a stub implementation that simply returns no data at all when plugin B tries to invooke functions of A ?
You are correct that there is no explicit support for optional imports yet.
There are a few options here depending on your exact requirements. Wasmtime can inspect component exports so you might be able to provide some interface that lets one plugin query the interfaces of other plugins via the host.
Wasmtime can also inspect imports so you could inject stub implementations for missing plugins.
There is also this feature, though it's a pretty big hammer: https://docs.rs/wasmtime/latest/wasmtime/component/struct.Linker.html#method.define_unknown_imports_as_traps
Last updated: Dec 06 2025 at 06:05 UTC