bytecodealliance / bytecodealliance/wac

Resolve import loop with ``use``

Open
#166 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
208
Forks
41
Avg merge
2d 7h
Merged PRs (30d)
3

Description

wac-cli version 0.7.0

Components _**xml-converter**_ and _**network-outgoing**_ implement interfaces defined in the **_core_** package and `use` the record _**error-detail**_ defined in the _**core-logic**_ interface. wasm-tools shows that after building said components with the commands `wasm-tools component wit xml-converter.wasm` and `wasm-tools component wit network-outgoing.wasm` both import `prototype:core/core-logic@0.1.0`. However, the **_core_** component depends on the interfaces implemented by the _**xml-converter**_ and _**network-outgoing**_ components, which creates an import loop. While testing with WasmCloud and its runtime linking via wrpc, this didn't cause an issue, and everything worked fine. But trying to compose the components with WAC results in the resulting component importing `prototype:core/core-logic@0.1.0`. Can this be solved somehow?

### **_core_** component:

```
package prototype:core@0.1.0;

interface core-logic {
enum error-code {
conversion-failed,
failed-to-get-product-list,
internal,
}

record error-detail {
code: error-code,
message: string,
}

get-product-list-csv: func(id: string, trace-id: string) -> result, error-detail>;
}

interface handler-outgoing {
use core-logic.{error-detail};

get-product-list: func(id: string, trace-id: string) -> result, error-detail>;
}

interface converter{
use core-logic.{error-detail};

convert: func(input: list, trace-id: string) -> result, error-detail>;
}

world core {
import converter;
import handler-outgoing;

export core-logic;
}
```

### _**network-outgoing**_ component:

```
package prototype:network-outgoing@0.1.0;

world network-outgoing {
import wasi:http/outgoing-handler@0.2.0;

export prototype:core/handler-outgoing@0.1.0;
}
```

### _**xml-converter**_ component:

```
package prototype:xml-converter@0.1.0;

world xml-converter {
export prototype:core/converter@0.1.0;
}
```

### _**network-incoming**_ component:

```
package prototype:network-incoming@0.1.0;

world network-incoming {
import prototype:core/core-logic@0.1.0;

export wasi:http/incoming-handler@0.2.0;
}
```

### WAC file:

```
package prototype:app@0.1.0;

let network-outgoing = new prototype:network-outgoing {...};
let xml-converter = new prototype:xml-converter {...};

let core = new prototype:core {
converter: xml-converter.converter,
handler-outgoing: network-outgoing.handler-outgoing,
...
};

let network-incoming = new prototype:network-incoming {
core-logic: core.core-logic,
...
};

export network-incoming.incoming-handler;
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.