Skip to content

Instantly share code, notes, and snippets.

@Pspritechologist
Pspritechologist / clip.lua
Last active February 10, 2026 20:02
Lua CLI to Convert a C# WASM Module to a Bare Module
#!/usr/bin/env lua
--[[
### The purpose of this script is to strip the Component-model and WASI requirements from a WASM module compiled
### with the experimental C# backend found here: https://github.com/dotnet/runtimelab/tree/feature/NativeAOT-LLVM/samples/NativeLibrary.
It can output the WAT/WASM at any given stage of modification for debug purposes, but the primary use is
simply `clip.lua input.wasm output.wasm`. `-v` to get status printed, `-h` for help, etc.
It depends on the Penlight library as well as having `wasm-tools` in your path. `wasm-tools` could *likely* be
replaced by something else, but that's the one I know :P