Hi, is there examples of linking two wasm component in the wasmtime?
In my example, 2nd component imports interface from 1st component.
first wit
package acme:first
interface first-service {
hello: func(msg: string)
}
world first-world {
export first-service
}
2nd wit depends on first
package acme:second
interface second-service {
hello: drive()
}
world second-world {
import first-service
export second-service
}
I tried something like this:
....
let first_comp = Component::from_file(&engine, &path1)?
let second_comp = Component::from_file(&engine, &path2)?;
let first_instance = linker.instantiate(&mut store, &first_comp)?; // this works
let second_instance = linker.instantiate(&mut store, &second_comp)?;. // this doesn't work
but result in error message something like
Error: import acme:first/first-service
has the wrong type
Caused by:
0: instance export hello
has the wrong type
1: expected func found nothing
nope, unlike the wasmtime module linker, the only thing the wasmtime component linker can do is link a component to host function definitions.
if you need to link components, we recommend you use wasm-tools compose
or the wasm-compose
crate
Got it. Linking thru compose works. Thanks
Hi bro. I'm got this error too. but I'm a newer for wasmtime and wasm. please help me. how to use it link to wasmtime
Last updated: Dec 23 2024 at 12:05 UTC