Skip to main content
Version: next

Building and publishing WebAssembly components

Wasm Shell (wash) is the comprehensive command-line tool for developing, building, and publishing WebAssembly components.

In this section of the Developer Guide, you'll learn how to:

  • Compile your project to a WebAssembly component binary
  • Publish your component to an OCI registry
Prerequisites

If you haven't completed the previous section on installing wash, creating a project, and starting a developer loop, we recommend starting there.

Building WebAssembly components

Use the wash build command from the root of a project directory to compile the component into a .wasm binary:

shell
wash build

The output path for the compiled .wasm binary varies by language toolchain and can be configured via wash's config.json file.

By default, the compiled .wasm binary for a Rust project is generated at /target/wasm32-wasip2/debug/.

You can find more options for the wash build command in the Command Reference.

Interface dependencies and wash build

When you run wash build, wash reads the specified world in your WIT files and downloads the appropriate dependencies automatically into the wit/deps directory. As such, in most cases you should add wit/deps to your .gitignore file.

Without any additional configuration, wash can download dependencies from the following namespaces (i.e. the wasi in wasi:http@0.2.1):

Components and OCI registries

Once you're finished iterating on your component, you can publish it to any OCI compliant registry that supports OCI artifacts. These artifacts are not container images, but conform to OCI standards and may be stored on any OCI-compatible registry.

Authenticating to OCI registries

wash supports the usage of Docker credentials for authentication to registries. There are multiple ways to authenticate with Docker credentials, including the docker login command with the docker CLI:

shell
docker login <registry> -u <username> -p <password-or-token> 

Publishing to OCI registries

Push the component to your registry:

shell
wash oci push ghcr.io/<namespace>/hello:0.2.0 ./dist/http-hello-world.wasm
  • The target registry address (including artifact name and tag) are specified for the first option with wash oci push.
  • The second option defines the target path for the component binary to push.