WACS.Transpiler.Lib 0.11.0

dotnet add package WACS.Transpiler.Lib --version 0.11.0
                    
NuGet\Install-Package WACS.Transpiler.Lib -Version 0.11.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WACS.Transpiler.Lib" Version="0.11.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WACS.Transpiler.Lib" Version="0.11.0" />
                    
Directory.Packages.props
<PackageReference Include="WACS.Transpiler.Lib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WACS.Transpiler.Lib --version 0.11.0
                    
#r "nuget: WACS.Transpiler.Lib, 0.11.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WACS.Transpiler.Lib@0.11.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WACS.Transpiler.Lib&version=0.11.0
                    
Install as a Cake Addin
#tool nuget:?package=WACS.Transpiler.Lib&version=0.11.0
                    
Install as a Cake Tool

WACS.Transpiler.Lib

Programmatic API for WACS's ahead-of-time WebAssembly → .NET IL transpiler. Reference this package when you want to drive transpilation, loading, and dispatch of saved .dlls from inside a host process — Unity / Godot embedders, ASP.NET workers, custom toolchains, build pipelines.

For one-shot CLI use (wacs build app.wasm -o app.dll), install WACS.Cli instead. This package is the library API behind that CLI.

Install

dotnet add package WACS.Transpiler.Lib

Quick start — in-process transpile + run

JIT-capable hosts (desktop, server, dotnet run, Godot Mono) can transpile and execute in one step using Reflection.Emit. Roughly 64× the WACS interpreter on compute-bound workloads (~17 500 vs ~270 iter/s on CoreMark, M3 Max).

using Wacs.Core;
using Wacs.Core.Runtime;
using Wacs.Transpiler.AOT;

var runtime = new WasmRuntime();
runtime.BindHostFunction<Action<int>>(("env", "log"), v => Console.WriteLine(v));

using var fs = File.OpenRead("app.wasm");
var module = BinaryModuleParser.ParseWasm(fs);
var moduleInst = runtime.InstantiateModule(module);

var transpiler = new ModuleTranspiler("MyApp.Wasm", new TranspilerOptions
{
    Simd = SimdStrategy.HardwareIntrinsics,
});
var result = transpiler.Transpile(moduleInst, runtime, "WasmModule");

// result.ModuleClass is a fresh CLR Type. Construct + invoke through
// the generated IExports / IImports interfaces.

Quick start — pre-compile + load (AOT-safe runtime)

For AOT-only targets that can't run Reflection.Emit (Unity IL2CPP, NativeAOT, iOS, Mono AOT), pre-compile on a JIT host and ship the .dll:

# On the build machine:
wacs build app.wasm -o app.dll

Then load it at runtime via TranspiledModuleLoader — same throughput, no Reflection.Emit dependency:

using Wacs.Core.Runtime;
using Wacs.Transpiler.Hosting;

var runtime = new WasmRuntime();
runtime.BindHostFunction<Action<int>>(("env", "log"), v => Console.WriteLine(v));

var loader = new TranspiledModuleLoader();
var loaded = loader.Load("app.dll", runtime);
// loaded.Invoke / loaded.Exports give you the typed surface

Component model

For component-mode wasm (the wasi-p2 / .component.wasm shape), pair this package with WACS.ComponentModel and use ComponentTranspiler.TranspileSingleModule:

using Wacs.Transpiler.AOT.Component;

using var fs = File.OpenRead("app.component.wasm");
var result = ComponentTranspiler.TranspileSingleModule(
    fs,
    assemblyNamespace: "MyApp.Wasm",
    moduleName: "Module",
    options: new TranspilerOptions
    {
        // HostPackageResolver auto-built when null — walks HostPackages
        HostPackages = new[]
        {
            typeof(Wacs.WASI.Preview2.Cli.CliBindings).Assembly,
            typeof(Wacs.WASI.Preview2.DependencyInjection.WasiPreview2Bundle).Assembly,
        },
    },
    configureImports: rt =>
    {
        // Wire WASI Preview 2 + custom IBindable host packages
    });

For WASI Preview 2 host wiring, the natural pairing is WACS.WASI.Preview2.DependencyInjection's WasiPreview2RuntimeScope — the same scope wacs run --wasip2 uses internally.

What's inside

  • ModuleTranspiler — core wasm → CIL emitter. Walks parsed instruction stream, emits CIL into a TypeBuilder, runs CilValidator at emit time
  • ComponentTranspiler — component-model variant; lifts/lowers canonical-ABI aggregates, integrates with HostPackageResolver for direct-link host imports
  • TranspiledModuleLoader — load saved .dlls without Reflection.Emit. Suitable for AOT targets
  • BindingLoader--bind assembly resolution + IBindable activation
  • HostPackageResolver — typed [WitSource] interface discovery + AppDomain fallback for impl-class lookups
  • Engine knobs--simd {scalar | intrinsics | interpreter}, --no-tail-calls, --max-fn-size, --data-storage {compressed | raw | static}, EmissionTarget.{Auto | Standard | AotLinked}

Mixed-mode + cold-start

Transpilation is opportunistic: any function the transpiler declines (e.g., very large bodies under --max-fn-size) falls back to the WACS interpreter for that function only, so the module still runs.

Cold-start ranges from ~30–55 ms on a default dotnet publish to ~1 ms with PublishReadyToRun + saved-.dll flow, and 501 µs cold for a fully-NativeAOT-published consumer. Full breakdown in docs/COLDSTART.md.

Spec compliance

Spec-equivalent to the WACS interpreter on the WebAssembly 3.0 test suite (473/473), verified continuously on macOS ARM64 and Linux x64.

Documentation

License

Apache-2.0

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.11.0 90 5/18/2026
0.9.0 88 5/16/2026
0.8.15 84 5/11/2026
0.8.14 95 5/10/2026
0.8.12 90 5/10/2026
0.8.10 90 5/10/2026
0.7.3 95 5/9/2026
0.5.0 89 5/1/2026
0.4.0 85 5/1/2026
0.3.0 99 4/23/2026
0.2.1 97 4/21/2026
0.2.0 94 4/21/2026