https://github.com/nalgeon/lua-wasi
Lua WASI build.
https://github.com/nalgeon/lua-wasi
lua wasi wasm
Last synced: 10 months ago
JSON representation
Lua WASI build.
- Host: GitHub
- URL: https://github.com/nalgeon/lua-wasi
- Owner: nalgeon
- License: mit
- Created: 2024-01-03T02:25:25.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-03T14:18:51.000Z (about 2 years ago)
- Last Synced: 2025-04-13T09:06:40.401Z (10 months ago)
- Topics: lua, wasi, wasm
- Language: C
- Homepage:
- Size: 258 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lua WASI build
This is a [WASI](https://wasi.dev/) build of the Lua 5.4 interpreter, compiled with [wasienv](https://github.com/wasienv/wasienv).
It is published as an NPM package [@antonz/lua-wasi](https://www.npmjs.com/package/@antonz/lua-wasi):
```
https://unpkg.com/@antonz/lua-wasi/dist/lua.wasm
```
## Usage
Using the [Runno](https://github.com/nalgeon/runno) runtime:
```js
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](https://antonz.org/), MIT License.
Lua is copyrighted by [Lua.org](https://www.lua.org/license.html), PUC-Rio, MIT License.