Currently playing around with replacing wasm sections with other sections. Is there a recommended way to go about doing that?
Specifically... interested in inlining import statements with an external wasm component
Been playing around with a few ways. May try and make a RawSection from wasm-encoder and just remove the raw bytes that are the import section
there isn't really a good framework for dealing with this kind of stuff. wasmparser and wasm-encoder is pretty much how it is done. you can look at various Mutator impls in wasm-mutate to get an idea of how these sorts of things have been done before
Thanks for the info! Yeah I was looking around there a bit too. I was getting the impression that it's primarily been used for core wasm modules, which I believe have some guarantees about section order that I know longer get to assume when working with components right?
I guess you could always just parse the whole thing and for each payload you get, encode precisely what you just parsed, except for replacing the specific section with some other component. Feels a little awkward but it would get the job done I think
It might also be worth checking out https://github.com/rustwasm/walrus
I'd be all for extending walrus to support components
I think I've found a way to meet my immediate needs using a combo of wasmparser and wasm-encoder. Could definitely be cool to help out with some walrus component support in the long term though
Last updated: Dec 06 2025 at 06:05 UTC