I am working on adding support for customizing the WIT package dependency directory path like:
wit_bindgen::generate!({ path: "../wit", deps: "../wit-deps" });
At the moment the deps directory is hardcoded in wit-parser's internal Resolve::_push_dir method:
fn _push_dir(&mut self, path: &Path) -> Result<(super::PackageId, PackageSourceMap)> {
let top_pkg = self
.parse_dir(path)
.with_context(|| format!("failed to parse package: {}", path.display()))?;
let deps = path.join("deps");
let deps = self
.parse_deps_dir(&deps)
.with_context(|| format!("failed to parse dependency directory: {}", deps.display()))?;
let (pkg_id, inner) = self.sort_unresolved_packages(top_pkg, deps)?;
Ok((pkg_id, PackageSourceMap::from_inner(inner)))
}
I would solve this by adding deps: impl AsRef<Path> as a parameter to the internal _push_dir method.
My question is if I should update the public push_dir method as well or if I should create a new push_dir_with_deps method instead?
Another question is then how we actually use this. As wit-bindgen relies on Resolve::push_path.
I am of the opinion to have wit-bindgen use Resolve::push_dir_with_deps in case a user provided a custom value for deps and path is a directory.
We could of course update Resolve::push_path as well but that would break a lot of things.
Let me know what you guys think is the best way forward.
Related GitHub issue: https://github.com/bytecodealliance/wit-bindgen/issues/1675
Maybe someone else has a better alternative solution, I am not really sure what’s acceptable :sweat_smile:
This seems reasonable to me, and I've also desired the same basic thing you desire but haven't done any of the actual work, so thanks for noodling on it
re https://github.com/bytecodealliance/wasm-tools/pull/2677
before I hit approve on that just want to flag for @Alex Crichton, do you have any thoughts or concerns on this?
nah that seems reasonable to me too!
Thanks for the quick response and merge! I’ll now keep an eye out for when a new wasm-tools release goes out and then update wasmtime and wit bindgen.
I am gonna look into writing some simple tests for custom dependency directories in wit-parser
I came to the realization that custom dependency directories would actually make sense for single WIT package files (non directories) as well. I am looking into adding support for this use case as well.
Here you go: https://github.com/bytecodealliance/wasm-tools/pull/2681
Could make a case that it could replace the previous API as a breaking change but I don't really feel comfortable updating all dependents and tests for this unique of a use case.
I do still plan to make another follow up PR to cover this with some tests.
Last updated: Oct 11 2026 at 04:10 UTC