You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two standard wit worlds that runtimes support. These worlds are the [`wasi:cli/command` world](https://github.com/WebAssembly/wasi-cli/blob/main/wit/command.wit) and the [`wasi:http/proxy` world](https://github.com/WebAssembly/wasi-http/blob/main/wit/proxy.wit). All other wit worlds and interfaces are considered to be custom. In the following sections, you'll see how to run components that implement either world, as well as how to invoke custom exports.
3
+
There are two standard WIT worlds that runtimes support.
4
+
These worlds are the [`wasi:cli/command` world](https://github.com/WebAssembly/wasi-cli/blob/main/wit/command.wit)
5
+
and the [`wasi:http/proxy` world](https://github.com/WebAssembly/wasi-http/blob/main/wit/proxy.wit).
6
+
All other WIT worlds and interfaces are considered to be custom.
7
+
In the following sections, you'll see how to run components that implement either world, as well as how to invoke custom exports.
[jco](https://github.com/bytecodealliance/jco) is a fully native JavaScript tool for working with components in JavaScript. It supports the [`wasi:cli/command` world](https://github.com/WebAssembly/wasi-cli/blob/main/wit/command.wit). `jco` also provides features for transpiling Wasm components to ES modules, and for building Wasm components from JavaScript and WIT.
3
+
[jco](https://github.com/bytecodealliance/jco) is a fully native JavaScript tool for working with components in JavaScript.
4
+
It supports the [`wasi:cli/command` world](https://github.com/WebAssembly/wasi-cli/blob/main/wit/command.wit).
5
+
`jco` also provides features for transpiling WebAssembly components to ECMAScript modules (ES modules),
6
+
and for building WebAssembly components from JavaScript and WIT.
4
7
5
8
To run a component with `jco`, run:
6
9
7
10
```sh
8
11
jco run <path-to-wasm-file><command-args...>
9
12
```
10
13
11
-
`jco`'s WASI implementation grants the component full access to the underlying system resources. For example, the component can read all environment variables of the `jco` process, or read and write files anywhere in the file system.
14
+
`jco`'s WASI implementation grants the component full access to the underlying system resources.
15
+
For example, the component can read all environment variables of the `jco` process,
16
+
or read and write files anywhere in the file system.
Copy file name to clipboardExpand all lines: component-model/src/running-components/wasmtime.md
+16-5Lines changed: 16 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,9 @@
1
1
# Wasmtime
2
2
3
-
[Wasmtime](https://github.com/bytecodealliance/wasmtime/) is the reference implementation of the Component Model. It supports running components that implement the [`wasi:cli/command` world](https://github.com/WebAssembly/wasi-cli/blob/main/wit/command.wit) and serving components that implement the [`wasi:http/proxy` world](https://github.com/WebAssembly/wasi-http/blob/main/wit/proxy.wit). Wasmtime can also invoke functions exported from a component.
3
+
[Wasmtime](https://github.com/bytecodealliance/wasmtime/) is the reference implementation of the Component Model.
4
+
It supports running components that implement the [`wasi:cli/command` world](https://github.com/WebAssembly/wasi-cli/blob/main/wit/command.wit)
5
+
and serving components that implement the [`wasi:http/proxy` world](https://github.com/WebAssembly/wasi-http/blob/main/wit/proxy.wit).
6
+
Wasmtime can also invoke functions exported from a component.
4
7
5
8
## Running command components with Wasmtime
6
9
To run a command component with Wasmtime, execute:
@@ -9,13 +12,17 @@ To run a command component with Wasmtime, execute:
9
12
wasmtime run <path-to-wasm-file>
10
13
```
11
14
12
-
> If you are using an older version of `wasmtime`, you may need to add the `--wasm component-model` flag to specify that you are running a component rather than a core module.
15
+
> If you are using an older version of `wasmtime`, you may need to add the `--wasm component-model` flag
16
+
> to specify that you are running a component rather than a core module.
13
17
14
-
By default, Wasmtime denies the component access to all system resources. For example, the component cannot access the file system or environment variables. See the [Wasmtime guide](https://docs.wasmtime.dev/) for information on granting access, and for other Wasmtime features.
18
+
By default, Wasmtime denies the component access to all system resources.
19
+
For example, the component cannot access the file system or environment variables.
20
+
See the [Wasmtime guide](https://docs.wasmtime.dev/) for information on granting access, and for other Wasmtime features.
15
21
16
22
## Running HTTP components with Wasmtime
17
23
18
-
You can now execute components that implement the [HTTP proxy world](https://github.com/WebAssembly/wasi-http/blob/main/wit/proxy.wit) with the `wasmtime serve` subcommand. [The Wasmtime CLI](https://github.com/bytecodealliance/wasmtime) supports serving these components as of `v14.0.3`.
24
+
You can execute components that implement the [HTTP proxy world](https://github.com/WebAssembly/wasi-http/blob/main/wit/proxy.wit) with the `wasmtime serve` subcommand.
25
+
[The Wasmtime CLI](https://github.com/bytecodealliance/wasmtime) supports serving these components as of `v14.0.3`.
19
26
20
27
To run a HTTP component with Wasmtime, execute:
21
28
```sh
@@ -29,6 +36,7 @@ Try out building and running HTTP components with one of these tutorials
29
36
2.[HTTP Auth Middleware tutorial](https://github.com/fermyon/http-auth-middleware#running-with-wasmtime) - compose a HTTP authentication middleware component with a business logic component
30
37
31
38
## Running components with custom exports
39
+
32
40
As of Wasmtime Version 33.0.0, there is [support for invoking components with custom exports](https://bytecodealliance.org/articles/invoking-component-functions-in-wasmtime-cli).
33
41
34
42
@@ -37,4 +45,7 @@ As an example, if your component exports a function `add` which takes two numeri
37
45
```sh
38
46
wasmtime run --invoke 'add(1, 2)'<path-to-wasm-file>
39
47
```
40
-
Make sure to wrap your invocation in single quotes and to include parentheses, even if your function doesn't take any arguments. For a full list of ways to represent the various wit types when passing arguments to your exported function, visit the [WAVE repo](https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-wave).
48
+
49
+
Make sure to wrap your invocation in single quotes and to include parentheses, even if your function doesn't take any arguments.
50
+
For a full list of ways to represent the various WIT types when passing arguments to your exported function,
51
+
visit the [WAVE repository](https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-wave).
0 commit comments