dotnet / dotnet-wasi-sdk

An SDK for building .NET projects as standalone WASI-compliant modules
MIT License
279 stars 12 forks source link

No document or examples for building a wasm library with js interop #25

Open serefarikan opened 1 year ago

serefarikan commented 1 year ago

This answer from @SteveSandersonMS points at a very attractive opportunity for many future users of the wasi sdk: build a standalone wasm output to be called from other environments.

It is stated that:

Since this SDK doesn't assume any JavaScript environment exists, there are no built-in JS interop APIs, so you would have to wire up your own way of calling into the host browser to interact with the Chrome extension APIs

It would be fantastic if we could have at least the most basic documentation for building wasm output from a C# library project, and calling out to a host environment. Further discussions in the referenced thread above aim for a higher bar: calling out to a host environment without assuming a browser or WASI. I am not asking for that.

If we could have a bare minimum example of calling out to a browser env and/or WASI, it would allow users such as myself to experiment with potentially the most common use case: building wasm output and calling it from a browser env, or embedding it into some WASI friendly cloud service in which it will be provided some interfaces to call.

This project is clearly the way forward for wasm support, so having these fundamentals would be great. I mean, even building a library and calling it from a host environment would be a great example. I may be missing something obvious, and in this case I'll welcome feeling like an idiot if someone can point me at the documentation or example I'm missing 😄

mhmd-azeez commented 1 year ago

We're exploring this possibility here: https://github.com/extism/csharp-pdk/pull/4