dvc94ch opened issue #13930:
Seems that there is no simple way to link an
Instance's export to anotherInstance's import. TheLinkerseems to assume that allimports andexports are fullfilled by theHostand that components have been prelinked before instantiation. However it seems that being able to do this at dynamically at runtime is a very useful feature. A motivating example would be loading a view-provider with a stream<u8> returned by a network-provider based on a mime-type.The API would work something like this:
use wasmtime::component::{Component, Linker, Store}; // 1. Instantiate the dependency first let mut linker: Linker<MyState> = Linker::new(&engine); let dependency_instance = linker.instantiate(&mut store, &dependency_component)?; // 2. Setup a fresh, clean linker for the plugin let mut plugin_linker: Linker<MyState> = Linker::new(&engine); // 3. Fetch the entire interface block from the dependency let content_export = dependency_instance .get_export(&mut store, None, "ns:pkg/content") .expect("Dependency must export the interface"); // 4. Feed the entire exported block into the plugin's required import slot plugin_linker.instance("ns:pkg/content")? .add_export(&content_export)?; // This maps all functions AND resources natively // 5. Instantiate the plugin safely let plugin_instance = plugin_linker.instantiate(&mut store, &plugin_component)?;
alexcrichton added the wasm-proposal:component-model label to Issue #13930.
alexcrichton commented on issue #13930:
This is at this time an intentional limitation of
Linkerin Wasmtime. It's something that would ideally be supported, I agree, but it would require a significant investment in implementation and could possibly require that Cranelift is present at link-time, which is not a previous requirement Wasmtime has ever had. For now the workaround is to use thefunc_new-style APIs and have the host intermediate, which I realize is slow but can at least functionally get you to where you want to go.
Last updated: Jul 29 2026 at 05:03 UTC