---
# System prepended metadata

title: Untitled

---

title = "SIP XXX - Spin Component Imports" 
template = "main" 
date = "2023-09-22T16:27:43Z"
---

Summary: A proposal to introduce component imports to the Spin 2.0 manifest.

Owner: <brian.hardock@fermyon.com>

Created: Sep 19, 2023

## Background / Goals
The Spin 2.0 framework will support executing preview2 WebAssembly components. These components will include `import` and `export` statements. This manifest proposal is to enable Spin developers the ability to expressly configure how to satisfy the imports of their components. Furthermore, developers should be enabled to use the exports of a component to satisfy the imports of another.

## Proposal

### Changes to Spin Manifest 
To support component imports, a new section will be added to the Spin 2.0 manifest design, `[component.<component-id>.import.<import-id>]`. The following sections describe the various options for specifying how to satisfy imports.

> NOTE: `import-id` refers to one of the several optional for naming imports as per the [Component Model Explainer](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#import-and-export-definitions).

### Reference by ID
Imports can be satisfied by associating an import with a component ID which links to a component defined elsewhere in the manifest.

```toml
[component.foobar.import."foo"]
source = "other"

[component.other]
source = { path = "bar.wasm" }
```

### Reference components in a registry
With a future component registry (i.e. `warg`), developers will be able to satisfy their
component's imports using registry references:

```toml
[component.foobar.import."foo"]
source = { registry = "bytecodealliance.org:foobar-dep", version = "1.2.3" }
```

### Satisfy import by projecting into a component
By specifying an export on a component import declaration, developers can project into the component specified by `source` to use a named export to satisfy the import.

```toml
[component.foobar.import."foo"]
source = "path/to/component.wasm"
export = "bar"
```

This example demonstrates how to use an export name `bar` from `"path/to/component.wasm"` to satisfy component `"foobar"`'s import named `"foo"`.

> NOTE: The format for each `export` is required to be a kebab-cased name or interface id (e.g. `foo:bar/baz`) as described by the [Component Model Explainer](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#import-and-export-definitions).