'Can Blazor create wasm modules without any UI references or code?

Looking at the Blazor documentation I get the impression that it is meant to be used to develop client side browser applications.

A subset of this should be creating WASM output in the same way Rust does, but I cannot see any documentation that explains how can I create standalone WASM output which then can be called from JavaScript or if I can do it at all.

So is it possible to use Blazor or Belero (its F# cousin, based on Blazor) to create wasm libraries and not full applications?



Solution 1:[1]

A subset of this should be creating WASM output in the same way Rust does

No.

Blazor runs on Mono. Mono itself is compiled to Wasm, but both Blazor and your software run as IL modules inside Mono. In the current implementation they are interpreted, not compiled to Wasm.

So is it possible to use Blazor [or ...] to create wasm libraries and not full applications?

No.

Update 2022: Mono is now just the dotnet runtime (6+) and you can now create Wasm code from C# without using Blazor.

The basic steps are here but I think you will need a little more to get a working app/library. Like installing the framework etc.

Solution 2:[2]

You can create ASP.NET Core Razor components class libraries. Those libraries can contains code only such as services, and js interop scripts.

I wrote this library for exemple to use some AWS services in a Blazor app : Aguacongas.AwsServices

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 agua from mars