bytecodealliance / bytecodealliance/componentize-go

Feature: Ignore optional export interfaces

Aperta
#68 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
17
Fork
8
Merge medio
6h 57m
PR unite (30g)
5

Descrizione

# Description
Currently running into a little issue with an SDK I'm writing. This SDK wraps, among other things, the `wasi:cli` and the `wasi:http` interfaces. The setup is something as follows.

WIT:
```
package jamesstocktonj1:componentize-sdk;

world http {
export wasi:http/incoming-handler@0.2.6;
}

world cli {
export wasi:cli/run@0.2.6;
}

world all {
include sdk;
include http;
include cli;
}
```

Componentize Go Toml:
```toml
wit_paths = ["./wit"]
worlds = [
"sdk",
"http",
"cli"
]
```

## Issue 1
When I import this package (for example the `net/wasihttp` path), it builds a component which exports BOTH `wasi:http` and `wasi:cli` and then same is true when trying to write a CLI application.

I've tried splitting the `gen/wit_exports` file into `gen/wit_exports_cli` and `gen/wit_exports_http` but `componentize-go` complains that:
```
Error: failed to encode component from module

Caused by:
0: failed to decode world from module
1: module was not valid
2: failed to find export of interface `wasi:cli/run@0.2.6` function `run`
```

## Issue 2
We also have a scenario where we want to export neither CLI or HTTP but instead just want to use the `http.Client` interface. This again causes the component to export both interface although neither are needed.

### Summary
- How can we make certain wit interfaces optional?
- Would it be possible to have optional exports depending on what Go module path is imported?
- Having a `go.mod` and `componentize-go.toml` for each path would be possible but quite wasteful
- Can this be done without having to specify a specific interface? e.g. `componentize-go --world foo build ...`
- Can we fix this in the Componentize Go build side?

For more context this is the SDK in question:
https://github.com/jamesstocktonj1/componentize-sdk

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci la configurazione usando i WIT worlds, componentize-go.toml e i file di gen/wit_exports, comprese le varianti separate CLI e HTTP. Inizia con il componentize-go build command e con l’errore di decodifica del world segnalato, quindi determina come dovrebbero funzionare la selezione del world o gli exports opzionali. Il lavoro è completato quando le build CLI, HTTP e client-only esportano solo le interfacce di cui hanno bisogno.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go, wasm
Ambito
build-system, tooling
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.