fix: enhance WIT validation and binding generation with source path s…#122
Merged
GordonSmith merged 1 commit intobytecodealliance:mainfrom Mar 25, 2026
Merged
Conversation
c732447 to
e84f5dd
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes #121 by enhancing the extension’s WASM-backed WIT validation and binding generation to include a source path plus a set of sibling/dependency WIT files, enabling correct resolution for packages split across multiple files.
Changes:
- Extend the
wit-validatorWIT interface + Rust guest implementation to acceptsource-pathandsource-files-jsonfor validation and binding generation. - Update the extension runtime (
src/wasmUtils.ts,src/validator.ts,src/extension.ts) to gather local WIT context (includingdeps/) and pass it into the WASM APIs. - Add regression tests and fixtures covering local import resolution and multi-file package validation.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wit-bindgen-wasm/wit/wit-bindgen.wit | Adds optional source-path and source-files-json parameters to validator + binding generation functions. |
| wit-bindgen-wasm/src/lib.rs | Implements multi-file resolve loading via SourceMap and wires new params into validation/binding paths. |
| wit-bindgen-wasm/Cargo.toml | Updates toml build-dependency version. |
| wit-bindgen-wasm/Cargo.lock | Lockfile updates for Rust dependency changes. |
| src/wasmUtils.ts | Collects WIT files from the source directory (and deps/) and forwards them to the WASM validator/generator. |
| src/validator.ts | Passes file path into detailed validation for better resolution context. |
| src/extension.ts | Passes a source path into binding generation so local imports can be resolved during generation. |
| tests/wasmUtils.test.ts | Updates mocks/expectations for the new WASM API parameters. |
| tests/import-resolution.test.ts | Adds end-to-end tests for sibling import resolution using a temp WIT package. |
| tests/grammar/issue-121/wit/a.wit | Adds grammar fixture representing issue #121 multi-file package setup (file A). |
| tests/grammar/issue-121/wit/b.wit | Adds grammar fixture representing issue #121 multi-file package setup (file B). |
| tests/bindings-generation.test.ts | Updates binding generation calls to match new WASM function signature. |
| package.json | Updates dev toolchain dependencies and adds overrides for TypeScript resolution. |
| package-lock.json | Updates lockfile for the bumped JS toolchain dependencies. |
e84f5dd to
c084748
Compare
…upport - Updated `generateBindingsFromWasm` to accept an optional source path for improved context during binding generation. - Modified `validateWitSyntaxDetailedFromWasm` to include source path for detailed validation. - Introduced recursive file collection for WIT files in `wasmUtils.ts` to support local imports. - Added tests for local import resolution and validation scenarios. - Updated WIT interface definitions to reflect new parameters for validation and binding functions. - Bumped dependencies in `Cargo.lock` and `Cargo.toml` for compatibility with new features. Fixes Packages split across multiple files fail Fixes bytecodealliance#121 Signed-off-by: Gordon Smith <[email protected]>
c084748 to
71644ef
Compare
Contributor
|
🎉 This change has been included in wit-idl-v0.3.31 🎉 The release is available on:
Your release-please bot 🚀🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…upport
generateBindingsFromWasmto accept an optional source path for improved context during binding generation.validateWitSyntaxDetailedFromWasmto include source path for detailed validation.wasmUtils.tsto support local imports.Cargo.lockandCargo.tomlfor compatibility with new features.Fixes Packages split across multiple files fail
Fixes #121