Oh, my expectation was that .wit files were kinda like protobuf files in that you can just have them mutually import eachother and have a "bank" of shared APIs, each with different packages.
EG:
wit
└── techaro
├── logger.wit // package techaro:logger
└── wasm-checker.wit // package techaro:wasm-checker
Is this not really designed for the monorepo case where you have a big generic library full of stuff and then your components reach into and pull from part of that?
Your example for simple WIT reuse is something I wish was in the docs because I didn't know where to put the files in order to make things Just Work:tm:. Is there a way to do this that doesn't involve having to make symlink farms for deps folders?
if you have a monorepo with lots of separate packages, a wit/ directory that has no wit files but only a deps/ directory with all named packages is fine too, then everything in your repo can refer to worlds by their package names
you can refer to the world by the full legal package name?
reading https://docs.rs/wit-bindgen/latest/wit_bindgen/macro.generate.html#options-to-generate doesn't give me the impression you can do that
putting in techaro:wasm-checker/checker works
yes you can refer to worlds with their full path for your use case :)
moving everything to a deps folder makes wit-bindgen break:
wit
└── deps
├── techaro:logger
│ └── logger.wit
└── techaro:wasm-checker
└── wasm-checker.wit
$ cargo build --target wasm32-unknown-unknown --release
Compiling is-modern-browser v0.1.0 (/Users/cadey/Code/Techaro/hivemind/wasm/is-modern-browser)
error: failed to resolve directory while parsing WIT for path [/Users/cadey/Code/Techaro/hivemind/wit]
Caused by:
failed to parse package: /Users/cadey/Code/Techaro/hivemind/wit
Caused by:
no `package` header was found in any WIT file for this package
--> wasm/is-modern-browser/src/lib.rs:5:1
|
5 | / wit_bindgen::generate!({
6 | | world: "techaro:wasm-checker/checker",
7 | | path: "../../wit",
8 | | generate_all,
9 | | });
| |__^
oh I thought that was fixed, your wit/ needs to define a package name which can just be package unused:unused; which is not intended, a wit directory purely with deps in it is supposed to be fine
ah, i see, that makes it work
Xe Iaso has marked this topic as resolved.
https://github.com/bytecodealliance/wit-bindgen/pull/1299 filed a docs PR
Last updated: Dec 06 2025 at 05:03 UTC