I am trying to build a very simple application with components that does not depend on any other packages. just some functions. When I compile my guest project to a core wasm module everything seems to be working just fine, with the output of wasm-tools component wit <core.wasm>
being
package root:root {
world root {
export hello-world: func() -> string;
}
}
package component:sus {
world example {
export hello-world: func() -> string;
}
}
However when i convert the core module to a component with
wasm-tools component new --adapt wasi_snapshot_preview1=latest_wasi_snapshot_preview1.reactor.wasm <core.wasm> -o component.wasm
It adds dependencies on a bunch of standard packages:
...
package root:component {
world root {
import wasi:cli/environment@0.2.0;
import wasi:cli/exit@0.2.0;
import wasi:io/error@0.2.0;
import wasi:io/streams@0.2.0;
import wasi:cli/stdin@0.2.0;
import wasi:cli/stdout@0.2.0;
import wasi:cli/stderr@0.2.0;
import wasi:clocks/wall-clock@0.2.0;
import wasi:filesystem/types@0.2.0;
import wasi:filesystem/preopens@0.2.0;
export hello-world: func() -> string;
}
}
I do not want to support these packages on my host so how can i avoid importing these?
If you're using Rust as a source language you can use the wasm32-unknown-unknown
target for this
oh great let me try that. is there documentation on this? i have only ever seen the wasm32-wasip1 target in use
No documentation I know of myself, but the workflow should be the same (note that things like println in the standard library won't work)
Ok so do i understand this correctly that the wasm32-wasip1 requires these core packages to be present to make the std lib work and wasm32-unknown-unknown does not and hence does not support the stdlib?
more or less yeah
It works! Thank you so much for your help!
lkjhaisduhjfkxcjvbnis has marked this topic as resolved.
Last updated: Dec 23 2024 at 13:07 UTC