Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 776 Bytes

File metadata and controls

31 lines (20 loc) · 776 Bytes

Zig wasm plugin example

This is a bare-bone typst plugin, written in Zig.

Compile

To compile this example, you need the zig compiler. Then, run the command

zig build-lib hello.zig -target wasm32-freestanding -dynamic -rdynamic -O ReleaseSmall

Compile with wasi

If you want to build with WASI, use the wasm32-wasi target:

zig build-lib hello.zig -target wasm32-wasi -dynamic -rdynamic -O ReleaseSmall -femit-bin=hello-wasi.wasm

Then, stub the resulting binary:

pushd ../../wasi-stub
cargo run -- ../examples/hello_zig/hello-wasi.wasm -o ../examples/hello_zig/hello-wasi.wasm
popd

Build with typst

Simply run typst compile hello.typ, and observe that it works !