Stream: cargo-component

Topic: Compile without wasi packages


view this post on Zulip Karl Smit (Feb 18 2025 at 00:38):

Hello, I may not be using this correctly but I wanted to see what the preferred way to do this is

I'm using wit-bindgen to define a world with imports and exports, that I would like my component to support as I am importing it into a program that will provide those imports and exports.

When compiling with cargo component build --release, and then inspecting with wasm-tools component wit ./path/to/module.wasm I'm noticing that in addition to my defined world, it has several other imports defined, namely to do with wasi:cli, wasi:io, wasi:clocks, wasi:filesystem

I dont need these for my component, and so Im wondering if theres a way to not include them in the build.

Thank you

view this post on Zulip Victor Adossi (Feb 18 2025 at 05:41):

Hey @Karl Smit to do that, compile with wasm32-unknown-unknown as a target -- that will remove the WASI dependencies.

See also:

#cargo-component > ✔ component imports instance `wasi:cli/environment@0.2.0`

#general > wit-bindgen rust host + guest: get-environment has the wrong


Last updated: Feb 27 2025 at 23:03 UTC