Stream: general

Topic: Import from other .wit file


view this post on Zulip Xe Iaso (May 19 2025 at 01:42):

Hey,

If I have two .wit files, how do I import types/interfaces/records from one .wit file into the other? Say one is:

// logger.wit
package techaro:logger;

interface sink {
  debug: func(msg: string);
  info: func(msg: string);
  warn: func(msg: string);
  error: func(msg: string);
}

world logger {
  import sink;
}

How do I use the techaro:logger/sink interface in another .wit file?

view this post on Zulip Alex Crichton (May 19 2025 at 04:12):

You might want to read over this and this to help answer this?

Repository for design and specification of the Component Model - WebAssembly/component-model
Repository for design and specification of the Component Model - WebAssembly/component-model

view this post on Zulip Victor Adossi (May 19 2025 at 09:27):

Also, note that you likely want to get the WIT that you're trying to share out into a properly "shared" place.

You don't have to go as far as actually publishing it, but you may benefit from separating the interface and the world that represents the usage of that interface

view this post on Zulip Victor Adossi (May 19 2025 at 09:37):

As for examples, I wish I could point to an example repo that shows this simply (the component model book is close, but we need to make changes to the WIT fetching instructions!)

But for now, the absolute simplest no-advanced-tooling way might be to literally copy the relevant WIT files into wit/deps for two projects locally. That should help build confidence as to what the tooling is expected to do, and then you can pull in wkg and stuff.

Would appreciate if you filed an issue to component-docs (the more you could include about what exactly was confusing, what the docs should have said/demonstrated to help you better, the better!)

Documentation around creating and using WebAssembly Components - bytecodealliance/component-docs

view this post on Zulip Victor Adossi (May 19 2025 at 09:51):

I've put together a small repo that should help explain this (but contains no integration code):

https://github.com/vados-cosmonic/example-simple-wit-reuse

Figure this might be better than giving tree output.

Simplest possible WIT reuse example. Contribute to vados-cosmonic/example-simple-wit-reuse development by creating an account on GitHub.

view this post on Zulip Victor Adossi (May 19 2025 at 09:53):

(all of this is useful after reading the already posted links of course!)


Last updated: Dec 06 2025 at 05:03 UTC