Stream: git-wasmtime

Topic: wasmtime / issue #13930 Implement `add_export` on `Linker...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 08:07):

dvc94ch opened issue #13930:

Seems that there is no simple way to link an Instance's export to another Instance's import. The Linker seems to assume that all imports and exports are fullfilled by the Host and 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)?;

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 14:28):

alexcrichton added the wasm-proposal:component-model label to Issue #13930.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2026 at 14:29):

alexcrichton commented on issue #13930:

This is at this time an intentional limitation of Linker in 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 the func_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