bytecodealliance / bytecodealliance/wasm-tools
Relax WIT directory structure
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 351
- Avg merge
- 16h 57m
- Merged PRs (30d)
- 38
Description
Zulip context: https://bytecodealliance.zulipchat.com/#narrow/stream/327223-wit-bindgen/topic/WIT.20directory.20structure
Currently, most WIT tooling expects a specific directory layout, typically rooted in a directory named `wit/`:
`wit/*.wit`: Mandatory "default" package
`wit/deps/*/*.wit`: Optional "dependency" packages, which can be referenced by other packages
The only way to store multiple packages in the same place is to (often arbitrarily) partition them into one default package and all others as "deps". This is awkward for repositories that don't have exactly one natural default package, such as the [WASI 0.2 repo](https://github.com/WebAssembly/WASI/tree/main/preview2) (ref #1433).
I'm proposing two changes:
* Relax this directory structure into basically one rule: any directory under a "WIT root" (including the root itself) that contains at least one `.wit` file will be parsed as a package.
* Update tooling to accept multiple WIT root directories to resolve, still defaulting to `["wit/"]` where appropriate.
These changes should be backward compatible with the existing layout and permit some new conventions, such as:
- The WASI 0.2 repo doesn't have to change; if someone wants to consume it directly they can point at the entire `preview2/` directory or individual `preview2/*` packages as WIT roots.
- Projects with many dependencies can organize them by namespace, e.g. `wit/wasi/{http,io}/*.wit`, `wit/my-namespace/my-package@1.0.0/*.wit`
- Registry tooling can use unambiguous paths with e.g. content-addressed files
Contributor guide
Assessment
This issue has not been assessed yet.