Stream: wasm

Topic: Optional imports in the component model


view this post on Zulip Alex Crichton (Aug 19 2025 at 18:05):

I've opened an issue on the component-model repo about a near-term plan for optional imports which if folks have thoughts on please feel free to drop them there or here!

Here I'd like to write up the result of some discussion that was had today about optional imports. In the fullness of time optional imports is expected to be a relatively complex feature that's int...

view this post on Zulip Theodore Brockman (Sep 24 2025 at 18:33):

@Alex Crichton Maybe related: I've been trying to model a plugin system where plugin authors may request optional host permissions (which won't necessarily all be granted by the user), where permissions end up translating to functionality linked by the host, but which shouldn't fail to instantiate if some capabilities are missing (and it's left to the guest to check at runtime whether necessary capabilities are available), ideally without requiring plugin authors to write any .wit themselves

Would I be correct in thinking that future phases of optional imports may help facilitate something like this? Am I making things unnecessarily complicated for myself, and I should just write some sort of capability discovery WIT interface, which returns optional resources? Not assuming I have a particularly novel use-case, so wondering what others have done here and what might be recommended.

view this post on Zulip Alex Crichton (Sep 25 2025 at 14:15):

You're thinking is about the same as mine, optional imports are probably the most natural implementation of this but in the meantime optional resource getters is probably the way to model this

view this post on Zulip Theodore Brockman (Sep 28 2025 at 19:41):

Well that's definitely encouraging to hear that I'm at least somewhat close to understanding things haha, thanks for the response.


Last updated: Dec 06 2025 at 05:03 UTC