I am looking for a way to create a component that includes two core modules with the wasm-tools component
.
I suppose those two modules can be linked together. First module is able to export second's import. like:
package local:logger
interface logging {
enum level {
error,
warn,
verbose,
debug,
}
log: func(l: level, s: string) -> result<_, u32>
}
world logger {
export logging
}
and
package local:demo
interface logging {
enum level {
error,
warn,
verbose,
debug,
}
log: func(l: level, s: string) -> result<_, u32>
}
world demo {
import logging
export run: func()
}
This PR (which was just merged yesterday) may be useful to you: https://github.com/bytecodealliance/wasm-tools/pull/1133
However, it doesn't use WIT or the canonical ABI for inter-module linking -- just core functions. There's a demo of how to use it here: https://github.com/dicej/component-linking-demo
If you're using WIT to declare the inter-module interfaces, you might as well just make them components and compose them at that level using wasm-tools compose
.
Does this mean I could take a pre-built wasm (like duckdb.wasm or onnx.wasm) and call any of their exports from my "app" and use this new link function to mash them all together into a single wasm?
lum1n0us has marked this topic as resolved.
Last updated: Nov 22 2024 at 16:03 UTC