lua-wasi

Lua WASI build.

MIT License

Downloads
25
Stars
5

Lua WASI build

This is a WASI build of the Lua 5.4 interpreter, compiled with wasienv.

It is published as an NPM package @antonz/lua-wasi:

https://unpkg.com/@antonz/lua-wasi/dist/lua.wasm

Usage

Using the Runno runtime:

import { WASI } from "https://unpkg.com/@antonz/runno/dist/runno.mjs";

const url = "https://unpkg.com/@antonz/lua-wasi/dist/lua.wasm";
const result = await WASI.start(fetch(url), {
    args: ["lua", "-v"],
    stdout: (out) => console.log(out),
    stderr: (err) => console.error(err),
});
console.log(`exit code = ${result.exitCode}`);

Result:

Lua 5.4.6  Copyright (C) 1994-2023 Lua.org, PUC-Rio
exit code = 0

Limitations

No detailed error messages for syntax errors in code.

No exception handling with pcall.

Unsupported stdlib functions:

io.tmpfile
os.execute
os.tmpname

Building from source

make
make dist

License

Copyright 2024 Anton Zhiyanov, MIT License.

Lua is copyrighted by Lua.org, PUC-Rio, MIT License.