How async support works in ComponentizeJS
mainComponentizeJS allows you to write exported functions as async functions, even though they are converted into synchronous component functions at the Wasm level.
When an exported function returns a Promise (e.g., when using fetch), ComponentizeJS automatically resolves the promise by running the event loop within the JS component until the value is ready.
Note: This asynchrony is only supported for exported functions. Imported functions must remain synchronous as component-model-level async support is not yet available.
export async function sayHello (name) {
const text = await (await fetch(`http://localhost:8080/${name}`)).text();
console.log(text);
}