Skip to content

fix: enhance WIT validation and binding generation with source path s…#122

Merged
GordonSmith merged 1 commit intobytecodealliance:mainfrom
GordonSmith:GH-121-WIT_IMPORT_ISSUE
Mar 25, 2026
Merged

fix: enhance WIT validation and binding generation with source path s…#122
GordonSmith merged 1 commit intobytecodealliance:mainfrom
GordonSmith:GH-121-WIT_IMPORT_ISSUE

Conversation

@GordonSmith
Copy link
Collaborator

…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 #121

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-validator WIT interface + Rust guest implementation to accept source-path and source-files-json for validation and binding generation.
  • Update the extension runtime (src/wasmUtils.ts, src/validator.ts, src/extension.ts) to gather local WIT context (including deps/) 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.

…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]>
@GordonSmith GordonSmith force-pushed the GH-121-WIT_IMPORT_ISSUE branch from c084748 to 71644ef Compare March 25, 2026 12:46
@GordonSmith GordonSmith merged commit 0121969 into bytecodealliance:main Mar 25, 2026
7 checks passed
@GordonSmith GordonSmith deleted the GH-121-WIT_IMPORT_ISSUE branch March 25, 2026 12:49
@github-actions
Copy link
Contributor

🎉 This change has been included in wit-idl-v0.3.31 🎉

The release is available on:

Your release-please bot 🚀🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Packages split across multiple files fail

2 participants