I'm trying to use wasmtime::component::bindgen!
on a wit like this I get a parse error like output
expected `import`, `export`, `use`, or type definition, found an identifier
// ..
world union-my-world {
include my-world-a
include my-world-b
}
Is there a possibility that include
statement is not supported yet?
My purpose here is to deduplicate the generated code between two worlds which shares dependencies.
Following the suggestion here: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#de-duplication-of-ids
According to the wit-parser
code base it is supported:
impl<'a> WorldItem<'a> {
fn parse(tokens: &mut Tokenizer<'a>, docs: Docs<'a>) -> Result<WorldItem<'a>> {
match tokens.clone().next()? {
//.. many patterns
Some((_span, Token::Include)) => Include::parse(tokens).map(WorldItem::Include),
other => Err(err_expected(
tokens,
"`import`, `export`, `include`, `use`, or type definition",
other,
)
.into()),
}
}
}
And here is my parse error.
On the other hand it says
"`import`, `export`, `include`, `use`, or type definition"
here.
So maybe wasmtime::component::bindgen!
uses a different version of the parser. Let me check further..
There hasn't yet been a release of wit-parser
that supports include
the PR landed on june 13, and a few bugfixes since then, but we havent cut a release. i expect we will once the resources work looks solid enough
Last updated: Dec 23 2024 at 13:07 UTC