Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to Generate Unused Types with bindgen!() Macro #10090

Open
AmmarAbouZor opened this issue Jan 23, 2025 · 0 comments
Open

Option to Generate Unused Types with bindgen!() Macro #10090

AmmarAbouZor opened this issue Jan 23, 2025 · 0 comments

Comments

@AmmarAbouZor
Copy link

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 the wit_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant