Skip to content

feat: add JavaScript bindings generation and transpilation for WIT co…#115

Merged
GordonSmith merged 1 commit intobytecodealliance:mainfrom
GordonSmith:JS_GEN
Mar 1, 2026
Merged

feat: add JavaScript bindings generation and transpilation for WIT co…#115
GordonSmith merged 1 commit intobytecodealliance:mainfrom
GordonSmith:JS_GEN

Conversation

@GordonSmith
Copy link
Collaborator

…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.

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

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.

@GordonSmith GordonSmith force-pushed the JS_GEN branch 6 times, most recently from 3958db1 to 2195401 Compare March 1, 2026 10:14
…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>
@GordonSmith GordonSmith merged commit a080925 into bytecodealliance:main Mar 1, 2026
7 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

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

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.

2 participants