Stream: wit-bindgen

Topic: ✔ Compose two components


view this post on Zulip Linwei Shang (Oct 18 2023 at 19:42):

Hi folks.
I'm exploring the capability of the component model and existing tools.
In this repo, I want to export a simple function bar() from the "secondary" component. And let the "primary" component to import that function.
The code in my repo now doesn't work.

$ cargo build -p primary --target wasm32-unknown-unknown
error: package not found
            --> /<project-root>/../wit/primary.wit:4:10
             |
           4 |   import example:secondary/foo;

It seems that the "wit" files contains some error. How can I make "primary.wit" be able to import an interface in "secondary.wit"?

$ cargo build -p secondary --target wasm32-unknown-unknown
error: expected `exports` map to contain key `example:secondary/foo`

It seems that I didn't use the wit_bindgen::generate!() macro correctly. But the doc of this proc-macro is not helpful.

Could you help me to fix the errors?
Or are there any related demo projects/examples? I haven't find any examples involve multiple "wit" files that cross-referencing.

Contribute to lwshang/wit-compose-demo development by creating an account on GitHub.

view this post on Zulip Linwei Shang (Oct 19 2023 at 15:04):

I managed to fix both errors.

view this post on Zulip Notification Bot (Oct 19 2023 at 15:05):

Linwei Shang has marked this topic as resolved.


Last updated: Oct 23 2024 at 20:03 UTC