Skip to content

Implement wit-tools print and refine the component interface - #52

Merged
scothis merged 2 commits into
componentized:mainfrom
scothis:wit-tools
Oct 7, 2026
Merged

scothis merged 2 commits into
componentized:mainfrom
scothis:wit-tools

Conversation

@scothis

@scothis scothis commented Oct 7, 2026

Copy link
Copy Markdown
Member

extract-wit.wasm -> wit-tools.wasm

wit-tools parses a wit-source (a wasm component or WIT package, WIT text, or a previously parsed wit) into the wit model, prints it back to WIT text, and summarizes a component's imports and exports. print rebuilds a wit-parser Resolve from the model and can include all, none, or selected additional packages. Core modules are rejected.

Interface changes, breaking for existing consumers:

  • types.component is renamed wasm, and error is renamed error-code
  • error-code gains malformed, not-component and not-found cases, which name the offending input for calls accepting several wasms

The loaders return the new error cases: not-found from the filesystem, OCI and HTTP loaders, an error for non-2xx HTTP responses rather than returning the body, and wac-loader validates each input component.

Adds unit tests for wit-tools and wac-loader, and wasmtime integration tests that run the wit-tools component, rebuilt with make before the tests read it. Cranelift and wasmtime are optimized in the dev profile so the integration tests compile the component quickly.

extract-wit.wasm -> wit-tools.wasm

wit-tools parses a `wit-source` (a wasm component or WIT package, WIT
text, or a previously parsed `wit`) into the `wit` model, prints it
back to WIT text, and summarizes a component's imports and exports.
`print` rebuilds a `wit-parser` Resolve from the model and can include
all, none, or selected additional packages. Core modules are rejected.

Interface changes, breaking for existing consumers:
- `types.component` is renamed `wasm`, and `error` is renamed
  `error-code`
- `error-code` gains `malformed`, `not-component` and `not-found` cases,
  which name the offending input for calls accepting several wasms

The loaders return the new error cases: not-found from the filesystem,
OCI and HTTP loaders, an error for non-2xx HTTP responses rather than
returning the body, and wac-loader validates each input component.

Adds unit tests for wit-tools and wac-loader, and wasmtime integration
tests that run the wit-tools component, rebuilt with make before the
tests read it. Cranelift and wasmtime are optimized in the dev profile
so the integration tests compile the component quickly.

Signed-off-by: Scott Andrews <scott@andrews.me>
Signed-off-by: Scott Andrews <scott@andrews.me>
@scothis
scothis merged commit 016c81f into componentized:main Oct 7, 2026
3 checks passed
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.

1 participant