| 1 |
<div align="center"> |
| 2 |
<h1><code>wasm-compose</code></h1> |
| 3 |
|
| 4 |
<strong>A <a href="https://bytecodealliance.org/">Bytecode Alliance</a> project</strong> |
| 5 |
|
| 6 |
<p> |
| 7 |
<strong>A WebAssembly component composing library.</strong> |
| 8 |
</p> |
| 9 |
|
| 10 |
<p> |
| 11 |
<a href="https://crates.io/crates/wasm-compose"><img src="https://img.shields.io/crates/v/wasm-compose.svg?style=flat-square" alt="Crates.io version" /></a> |
| 12 |
<a href="https://crates.io/crates/wasm-compose"><img src="https://img.shields.io/crates/d/wasm-compose.svg?style=flat-square" alt="Download" /></a> |
| 13 |
<a href="https://docs.rs/wasm-compose/"><img src="https://img.shields.io/static/v1?label=docs&message=wasm-compose&color=blue&style=flat-square" alt="docs.rs docs" /></a> |
| 14 |
</p> |
| 15 |
</div> |
| 16 |
|
| 17 |
## Overview |
| 18 |
|
| 19 |
**IMPORTANT**: `wasm-compose` has been been deprecated in favor of [`wac`](https://github.com/bytecodealliance/wac). |
| 20 |
|
| 21 |
`wasm-compose` is a library for composing [WebAssembly components](https://github.com/webassembly/component-model) |
| 22 |
from other WebAssembly components. |
| 23 |
|
| 24 |
It is made available as the `compose` subcommand of `wasm-tools`. |
| 25 |
|
| 26 |
## Usage |
| 27 |
|
| 28 |
To compose a component, run the `compose` command: |
| 29 |
|
| 30 |
```sh |
| 31 |
wasm-tools compose -o composed.wasm component.wasm |
| 32 |
``` |
| 33 |
|
| 34 |
This will automatically search for dependencies at the same location |
| 35 |
as the input component, `component.wasm`, and create a composed |
| 36 |
component named `composed.wasm`. |
| 37 |
|
| 38 |
Any unresolved dependencies will remain as imports in the composed |
| 39 |
component. |
| 40 |
|
| 41 |
## Configuration |
| 42 |
|
| 43 |
See [configuring `wasm-compose`](CONFIG.md) for more information on authoring configuration files. |
| 44 |
|
| 45 |
## How it works |
| 46 |
|
| 47 |
`wasm-compose` starts with the input component and then processes each of the component's instance imports. |
| 48 |
|
| 49 |
For each instance import, `wasm-compose` will consult its configuration to determine how to locate a dependency with the same name as the import. |
| 50 |
|
| 51 |
If the dependency is not specified in the configuration, `wasm-compose` will search the configured search paths for a matching component file. |
| 52 |
|
| 53 |
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. |
| 54 |
|
| 55 |
`wasm-compose` then repeats this process for all of the transitive imports of dependent components that have been found. |
| 56 |
|
| 57 |
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. |
| 58 |
|
| 59 |
Finally the input component is instantiated and all of its exports are then exported from the composed component. |
| 60 |
|
| 61 |
## Example |
| 62 |
|
| 63 |
See the [example](example/README.md) directory for a complete example |
| 64 |
of composing WebAssembly components together. |
| 65 |
|
| 66 |
## License |
| 67 |
|
| 68 |
This project is licensed under the Apache 2.0 license with the LLVM exception. |
| 69 |
See [LICENSE](../../LICENSE) for more details. |
| 70 |
|
| 71 |
### Contribution |
| 72 |
|
| 73 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 74 |
for inclusion in this project by you, as defined in the Apache-2.0 license, |
| 75 |
shall be licensed as above, without any additional terms or conditions. |