A Lua parser and transpiler to JavaScript that generates Mozilla Parser API ASTs. The current version is 0.0.11, with no recent releases or active development evident. It targets Lua 5.1 with partial support and aims to run unmodified Lua programs in JavaScript environments. Unlike other Lua transpilers, it provides options for Lua-JS interop such as automatic conversion of LuaTable to arrays/objects and method call syntax remapping. It requires no runtime dependencies and is distributed as a single minified file. The project has significant gaps: many standard library functions (e.g., string.format, pattern matching, coroutines, debug) are missing, and certain Lua syntax features (expression table keys, goto) are unsupported. The repository appears to be in maintenance or abandoned state.
npm install lua2jsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Parses a Lua Fibonacci function and translates it to JavaScript, demonstrating basic usage of parse and translate.
Implement missing functionality or avoid using those functions in Lua code.
Use string or numeric keys only in table literals.
Avoid long form strings with ]] sequences; use regular strings with escaped quotes if possible.
Consider alternative Lua-to-JS transpilers such as lua.js, moonscript, or fengari.
Do not rely on _ENV or _G; assign globals directly.
Replace {[expr]=value} with a string key or compute the value after table creation.Include the lua2js runtime library (dist/lua2js.runtime.js) in your project.
Use import lua2js from 'lua2js' or require('lua2js') and then call lua2js.parse.No dependency data recorded yet.