Stream: general

Topic: ✔ Pack two modules into one component


view this post on Zulip lum1n0us (Aug 10 2023 at 10:11):

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()
}

view this post on Zulip Joel Dice (Aug 10 2023 at 14:01):

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

Per https://github.com/WebAssembly/component-model/blob/main/design/mvp/examples/SharedEverythingDynamicLinking.md and https://hackmd.io/IlY4lICRRNy9wQbNLdb2Wg. This adds a new component link subco...
Demo of shared-everything linking using the WebAssembly Component Model - GitHub - dicej/component-linking-demo: Demo of shared-everything linking using the WebAssembly Component Model

view this post on Zulip Joel Dice (Aug 10 2023 at 14:02):

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.

view this post on Zulip Gordon Smith (Aug 12 2023 at 08:23):

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?

view this post on Zulip Notification Bot (Aug 14 2023 at 01:06):

lum1n0us has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC