feat: add JavaScript bindings generation and transpilation for WIT co…#115
Merged
GordonSmith merged 1 commit intobytecodealliance:mainfrom Mar 1, 2026
Merged
feat: add JavaScript bindings generation and transpilation for WIT co…#115GordonSmith merged 1 commit intobytecodealliance:mainfrom
GordonSmith merged 1 commit intobytecodealliance:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds JavaScript/TypeScript bindings generation and host-module transpilation to the vscode-wit extension (via @bytecodealliance/jco), expands command surface (guest/host bindings + docs), and significantly increases unit test coverage across formatting, validation, and WASM utilities.
Changes:
- Add JS bindings generation (
types) and host transpilation (transpile) utilities, plus corresponding VS Code commands/menus. - Refactor/rename binding generation commands into “guest” vs “host” groupings and add Markdown docs generation command wiring.
- Add extensive Vitest coverage configuration and new unit tests (validator, formatter edge cases, wasm detection/utils, JS bindings).
Reviewed changes
Copilot reviewed 28 out of 33 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| wit-bindgen-wasm/Cargo.toml | Bumps wasm-bindgen and web-sys versions for the WASM subproject. |
| wit-bindgen-wasm/Cargo.lock | Lockfile updates corresponding to Rust dependency bumps. |
| vitest.config.ts | Enables V8 coverage reporting and configures report outputs. |
| tests/wasmUtils.test.ts | Adds unit tests for wasmUtils with mocked VS Code + wasm module. |
| tests/wasmDetection-fs.test.ts | Adds file-based tests for wasm header reading/component detection. |
| tests/validator-methods.test.ts | Adds tests for WitSyntaxValidator error parsing and diagnostics creation. |
| tests/test-wit-validator.js | Adds/updates a test helper file (appears empty in provided diff). |
| tests/js-bindings.test.ts | Adds tests for JS guest/host bindings + host transpilation + command contributions. |
| tests/formatter-edge.test.ts | Adds formatter edge-case coverage (indentation, comments, aliases, etc.). |
| tests/bindingsSource.test.ts | Adds tests for deciding between path-based vs in-memory WIT generation. |
| src/jsBindings.ts | Implements JS bindings generation and component-to-host transpilation wrappers around jco. |
| src/formatter.ts | Minor formatter refactor (removes unused intermediate variable). |
| src/extension.ts | Adds JS binding commands, reorganizes guest binding commands, and wires new menus/flows. |
| src/bindingsSource.ts | Introduces helpers to detect whether path-based generation is safe/possible. |
| samples/greeter/wit/world.wit | Adds sample WIT world for greeter component. |
| samples/greeter/src/lib.rs | Adds sample Rust component implementation for greeter. |
| samples/greeter/Cargo.toml | Adds greeter sample crate manifest. |
| samples/counter/wit/world.wit | Adds sample WIT world for counter resource component. |
| samples/counter/src/lib.rs | Adds sample Rust component implementation for counter resource. |
| samples/counter/Cargo.toml | Adds counter sample crate manifest. |
| samples/adder/wit/world.wit | Adds sample WIT world for adder component. |
| samples/adder/src/lib.rs | Adds sample Rust component implementation for adder. |
| samples/adder/Cargo.toml | Adds adder sample crate manifest. |
| samples/build.sh | Adds script to build all sample components. |
| samples/README.md | Documents sample projects, build steps, and inspection workflow. |
| samples/Cargo.toml | Adds a Cargo workspace for samples. |
| samples/Cargo.lock | Adds lockfile for samples workspace dependencies. |
| samples/.gitignore | Ignores sample build artifacts. |
| package.json | Adds jco + coverage tooling, renames/extends commands/menus, adds build/test scripts. |
| .vscode/launch.json | Updates launch configs and adds a “samples” launch target. |
| .prettierignore | Ignores sample build output from formatting. |
| .gitignore | Ignores sample build output and coverage artifacts. |
3958db1 to
2195401
Compare
…mponents - Implemented `generateJsBindings` and `generateJsBindingsFromPath` for generating TypeScript bindings from WIT content. - Added `transpileJsHost` and `transpileJsHostFromPath` for transpiling WebAssembly components into JavaScript host modules. - Introduced interfaces and types for binding options and results. - Created tests for guest and host bindings generation, including complex WIT definitions and command contributions. - Ensured backward compatibility with deprecated aliases for guest and host bindings. - Implemented edge case tests for WitFormatter to ensure proper formatting of various input scenarios. - Added comprehensive tests for WitSyntaxValidator, covering error parsing and diagnostic creation. - Introduced file-based tests for WASM detection utilities to validate header reading and component identification. - Enhanced vitest configuration to include coverage reporting for better test insights. - Added a new command for running unit tests with coverage. Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
Contributor
|
🎉 This change has been included in wit-idl-v0.3.28 🎉 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.
…mponents
generateJsBindingsandgenerateJsBindingsFromPathfor generating TypeScript bindings from WIT content.transpileJsHostandtranspileJsHostFromPathfor transpiling WebAssembly components into JavaScript host modules.