npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

libwasmoon

v0.3.1

Published

A real lua VM with JS bindings made with webassembly (library version for embeddable lua bundles)

Readme

Based on ❤️ wasmoon

libwasmoon

A real lua VM with JS bindings made with webassembly (library version for embeddable lua bundles)

About

Libwasmoon is a javascript template which allows to run Lua code in the browser.

It is based on the wasmoon project and works by loading base64-encoded versions of custom-tailored Lua binaries. This allows to embed compiled Lua bundles and native Lua modules (e.g. written in C) via WebAssembly.

The result is a single javascript file which runs Lua code that can interact with the DOM / javascript APIs and vice versa – meaning that other <script>-tags can interact with variables and functions provided by Lua (see Interacting with Javascript APIs).

Feature Additions

  • Compile modules into a single javascript file
  • Support for native Lua modules (e.g. written in C)
    • Provides a system interface for most POSIX features via WASI

Usage

The template is designed to work together with lrc (the LRocket-compiler) which targets WebAssembly.

Installing the WebAssembly target for the LRocket compiler:

> luarocks install lrocket-build-wasm

The compiler provides three targets for WebAssembly:

You can compile to Javascript, to include your code as javascript module:

> lrc --otype wasm-js main.lua -o output-lib.js

You can compile directly to HTML, to write your complete page in Lua (starting off with window.document.body.innerHTML = [[...]]):

> lrc --otype wasm-html main.lua -o index.html

Or compile to .wasm to handle the embedding into the libwasmoon template yourself:

> lrc --otype wasm main.lua -o lua-module.wasm

If you would like to handle the compilation yourself (e.g. use a different compiler than lrc) virtually any compiler that targets wasm32 can be used to build your own Lua binary script.

For details see Using a Different Compiler.

Interacting with Javascript APIs

Libwasmoon makes the window-object available inside the global Lua environment – This allows to use any desired Javascript API via Lua syntax!

All is made possible by the fantastic work of the wasmoon project!

Examples

Button Callback

window.document.innerHTML = '<button>Click me!</button>'

-- for syntactic convenience we can export all contents of 'window.<...>' to the global environment
setmetatable(_G, { __index = window })

local button = document.querySelector 'button'
button.addEventListener('click', function()
    alert('Lua function called!')
end)

Lua Function in Javascript

function window.myLuaFunction()
    return math.random(1, 42)
end
// in javascript
alert('The answer to everything is: ' + myLuaFunction());

Geo Location

window.navigator.geolocation.getCurrentPosition(function(loc)
    -- prints to console.log()
    print('You are here', loc.coords.latitude, loc.coords.longitude)
end)

Using a Different Compiler

Any compiler that targets wasm32 (ideally wasm32-wasi / wasm32-wasi-threads) can be used to build the binary that will be embedded into the libwasmoon template.

The compiled binary should export a symbol named void __lr_entrypoint(lua_State *L) (called by libwasmoon after the Lua-state has been initialized).

We recommend linking against lua-wasm32, which is a static lua library (the one lrc links against when compiling bundles for WebAssembly). It is available via luarocks (note that the rock also ships a copy of the libwasmoon template):

> luarocks install lua-wasm32

For example, the clang-compiler could be used to compile a custom lua interpreter which can then be embedded into the libwasmoon template:

> clang --target=wasm32-wasi-threads -o lua-module.wasm my-custom-interpreter.c \
    <path-to-lua-wasm32>/lib/liblua-5.4.a

Turining lua-module.wasm into Javascript:

> sed dist/loader.js.tpl "s/{{libwasmoon:wasm_bytes}}/$(base64 -w0 lua-module.wasm)/g" > \
    output-lib.js

Using the module in HTML:

<!DOCTYPE html>
<body></body>
<script src="output-lib.js"></script>

You may also embed the script between an inline <script>...</script>-tag.

License

Just like wasmoon, libwasmoon is licensed under the MIT License.


Created by Lesosoftware in 2025