16 releases

0.2.11 Mar 10, 2023
0.2.9 Feb 23, 2023
0.2.1 Nov 21, 2022
0.0.0 Jun 28, 2022

#85 in WebAssembly

Download history 59/week @ 2022-11-28 55/week @ 2022-12-05 68/week @ 2022-12-12 71/week @ 2022-12-19 54/week @ 2022-12-26 118/week @ 2023-01-02 93/week @ 2023-01-09 228/week @ 2023-01-16 133/week @ 2023-01-23 237/week @ 2023-01-30 265/week @ 2023-02-06 256/week @ 2023-02-13 267/week @ 2023-02-20 183/week @ 2023-02-27 191/week @ 2023-03-06 120/week @ 2023-03-13

793 downloads per month
Used in wasm-tools

Apache-2.0 WITH LLVM-exception

1MB
23K SLoC

wasm-compose

A Bytecode Alliance project

A WebAssembly component composing library.

Crates.io version Download docs.rs docs

Overview

wasm-compose is a library for composing WebAssembly components from other WebAssembly components.

It is made available as the compose subcommand of wasm-tools.

Implementation status

A quick note on the implementation status of the component model proposal:

At this time of this writing, no WebAssembly runtimes have fully implemented the component model proposal.

Wasmtime has implementation efforts underway to support it.

Usage

To composed a component, run the compose command:

wasm-tools compose -o composed.wasm component.wasm

This will automatically search for dependencies at the same location as the input component, component.wasm, and create a composed component named composed.wasm.

Any unresolved dependencies will remain as imports in the composed component.

Configuration

See configuring wasm-compose for more information on authoring configuration files.

How it works

wasm-compose starts with the input component and then processes each of the component's instance imports.

For each instance import, wasm-compose will consult its configuration to determine how to locate a dependency with the same name as the import.

If the dependency is not specified in the configuration, wasm-compose will search the configured search paths for a matching component file.

If a component to satisfy the dependency cannot be found, it will remain as an instance import in the composed component; at least one dependency must be satisfied for the component to be composed.

wasm-compose then repeats this process for all of the transitive imports of dependent components that have been found.

The composed component will, by default, define the transitive component dependencies directly in the composed component; it will then instantiate the dependencies in a topological order.

Finally the input component is instantiated and all of its exports are then exported from the composed component.

Example

See the example directory for a complete example of composing WebAssembly components together.

License

This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Dependencies

~6MB
~159K SLoC