Stream: wit-bindgen

Topic: Exported Resources


view this post on Zulip Joe Sylve (Aug 28 2024 at 19:38):

I just wanted to confirm that this is a bug and that I'm not doing something wrong before I report it.

If I have the following, both resource-a and resource-b are treated as exported GuestResources as I'd expect.

world example {
    export some-interface;
}

interface some-interface {
    resource resource-a {

    }

    resource resource-b {
        get-a: func() -> result<resource-a>;
    }
}

However, if I define them in separate interfaces, only resource-b seems to be treated as an exported resource.

world example {
    export some-other-interface;
}

interface some-interface {
    resource resource-a {

    }
}

interface some-other-interface {
    use some-interface.{resource-a};

    resource resource-b {
        get-a: func() -> result<resource-a>;
    }
}

view this post on Zulip Joel Dice (Aug 28 2024 at 19:44):

I believe that is intended behavior, and it's also been a recurring source of confusion. See https://github.com/WebAssembly/component-model/issues/208

One of the subtelties of imports and exports in WIT is that they both need to somehow resolve their transitive dependencies. For example this world: package foo:bar interface foo { type t = u32 } i...

view this post on Zulip Joel Dice (Aug 28 2024 at 19:46):

If you add export some-interface; to your world in the second example, it should work like the first example.

view this post on Zulip Joe Sylve (Aug 28 2024 at 19:50):

That is confusing. I would expect that a resource that is exported via an exported function (either in the interface, world, or an exported resource) would also be exported regardless. Thanks for the insight. I'll read through that issue and comment if necessary.


Last updated: Oct 23 2024 at 20:03 UTC