72 releases (26 breaking)

0.220.0 Nov 12, 2024
0.218.0 Sep 30, 2024
0.215.0 Jul 31, 2024
0.202.0 Mar 26, 2024
0.0.0 Jun 28, 2022

#1628 in WebAssembly

Download history 1828/week @ 2024-08-04 2733/week @ 2024-08-11 3043/week @ 2024-08-18 3744/week @ 2024-08-25 5114/week @ 2024-09-01 3871/week @ 2024-09-08 2728/week @ 2024-09-15 2825/week @ 2024-09-22 3488/week @ 2024-09-29 3470/week @ 2024-10-06 3667/week @ 2024-10-13 6833/week @ 2024-10-20 8357/week @ 2024-10-27 5561/week @ 2024-11-03 4300/week @ 2024-11-10 6674/week @ 2024-11-17

25,353 downloads per month
Used in 21 crates (4 directly)

Apache-2.0…

2MB
40K SLoC

wasm-compose

A Bytecode Alliance project

A WebAssembly component composing library.

Crates.io version Download docs.rs docs

Overview

IMPORTANT: wasm-compose has been been deprecated in favor of wac.

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

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

Usage

To compose 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

~8MB
~150K SLoC