Howdy, all, I have a test working that complies a wasm file (using WIT, with wit_bindgen_guest_rust::generate!), in a separate project, and then another project that loads said file and encodes it to a component (via wit-component ComponentEncoder), and then execute the fn via Wasmtime, using wasmtime::component::bindgen! . All good.
However, unlike working with wasmtime Modules, converting the compiled wasm to wat and then using wat::parse_bytes/file to convert it .wasm again results in an error trying to find the exported function using the same toolchain. Is this expectation correct for this toolchain? I just wanted to make sure.
Yes roundtripping the core module loses custom sections which are used by wit component. Round tripping the component should work though
@Alex Crichton gotcha and thanks. That makes sense to me. I'll test through roundtripping the component. Is there a way to dynamically check if the incoming bytes represent a component vs mod without trying to use wast? Probably can decode metadata from the incoming representation?
Yes you can check the first 8 bytes to see whether it's a component or a core wasm module
@Alex Crichton does work indeed, thanks again.
Last updated: Dec 23 2024 at 12:05 UTC