AmmarAbouZor opened issue #10090:
Hi, first of all, I want to thank you all for the great work and effort you’ve put into this project.
Feature Request
It would be incredibly helpful to have the option to generate unused types when using the
wasmtime::component::bindgen!()
macro, similar to the functionality provided by thewit_bindgen::generate!()
macro.
I’ve included a code example below to illustrate the desired functionality:WIT File:
package example:example; interface types { record referenced-type { field: string } record no-ref-type { filed: string } fn: func(t: referenced-type); } world example { import types; }
Code in Rust:
mod wsm { wasmtime::component::bindgen!({ path: "wit", // NOTE: no equivalent for this option provided // generate_unused_types: true, }); use self::example::example::types::{ ReferencedType, // NoRefType: This type won't get generated }; } mod wit { wit_bindgen::generate!({ path: "wit", generate_unused_types: true, }); use self::example::example::types::{NoRefType, ReferencedType}; }
Benefit
Generating unused types can be really useful when we aim to group shared types into a single package and generate them only once for use across multiple other packages.
Alternatives
The current workaround involves adding unused worlds, interfaces, or functions that reference the desired types, ensuring they are generated.
fitzgen assigned pchickey to issue #10090.
pchickey commented on issue #10090:
Thank you for reporting this bug. I apologize that this sat for a long time without a response. We noticed it in our triage yesterday and I have a fix in #10311.
pchickey closed issue #10090:
Hi, first of all, I want to thank you all for the great work and effort you’ve put into this project.
Feature Request
It would be incredibly helpful to have the option to generate unused types when using the
wasmtime::component::bindgen!()
macro, similar to the functionality provided by thewit_bindgen::generate!()
macro.
I’ve included a code example below to illustrate the desired functionality:WIT File:
package example:example; interface types { record referenced-type { field: string } record no-ref-type { filed: string } fn: func(t: referenced-type); } world example { import types; }
Code in Rust:
mod wsm { wasmtime::component::bindgen!({ path: "wit", // NOTE: no equivalent for this option provided // generate_unused_types: true, }); use self::example::example::types::{ ReferencedType, // NoRefType: This type won't get generated }; } mod wit { wit_bindgen::generate!({ path: "wit", generate_unused_types: true, }); use self::example::example::types::{NoRefType, ReferencedType}; }
Benefit
Generating unused types can be really useful when we aim to group shared types into a single package and generate them only once for use across multiple other packages.
Alternatives
The current workaround involves adding unused worlds, interfaces, or functions that reference the desired types, ensuring they are generated.
AmmarAbouZor commented on issue #10090:
@pchickey Thanks a lot for resolving this issue—no need to apologize.
I really appreciate the monster work you've been doing on this project, and naturally, some issues take time to resolve :+1:
Last updated: Apr 18 2025 at 04:04 UTC