package example:add;
interface add {
add: func(a: u32, b: u32) -> u32;
}
world adder {
export add;
}
world anotheradder {
export add;
}
I have the following .wit file, now when I compile the adder
component with cargo component
why isn't the wit metadata (the world and package name) included in the component?
$ wasm-tools component wit target/wasm32-wasi/release/adder.wasm
package root:component;
world root {
export example:add/add;
}
I think it should instead be:
package example:add;
world adder {
export example:add/add;
}
This would make it easier to verify if a component targets a world, because right now I have to.
$ wasm-tools component targets -w adder ./wit/world.wit target/wasm32-wasi/release/adder.wasm
It would be a lot easier to just be able to:
$ wasm-tools component targets ./wit/world.wit target/wasm32-wasi/release/adder.wasm
Maybe wasm-tools
could even be helpful and output that the component targets the adder
world.
Also maybe comments of the wit file can be retained in the component for documentation
the name of a world
and the origin of its package is lost when you create a component, only the provenance of interface
items is retained. The wasm-tools component wit
subcommand effectively synthesizes the strings "root" and "component" there in package root:component;
and world root
. In that sense you won't be able to retain world adder
or world anotheradder
. There's various reasons for this I can expand on if you're interested as well.
As for documentation, that'd be nice to have! The WIT-to-wasm-encoded-WIT preserves comments, but we currently don't preserve comments when a component itself is created. That seems like a good idea though! If you're up for it mind opening an issue?
The issue would need to be opened for cargo component right?
If those synthetic names are needed for some implementation/ specification reason, can the original world and package maybe be included as metadata in the binary which is then used by tools like "targets".
Something like this
;; rootFromWorld=adder
;; rootFromPackage=example:add
https://github.com/bytecodealliance/cargo-component/issues/229
Oh sorry this'd probably be an issue for the wasm-tools
repo, but we can take it from here! Thanks!
(busy day for me)
i caught this on github before zulip but https://github.com/WebAssembly/component-model/issues/213 is the CM spec issue about this
agree that an issue for implementing it would need to be on BytecodeAlliance/wasm-tools
Last updated: Dec 23 2024 at 12:05 UTC