{"id":25907,"library":"lua2js","title":"Lua2JS","description":"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.","status":"abandoned","version":"0.0.11","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/basicer/lua2js-dist","tags":["javascript"],"install":[{"cmd":"npm install lua2js","lang":"bash","label":"npm"},{"cmd":"yarn add lua2js","lang":"bash","label":"yarn"},{"cmd":"pnpm add lua2js","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import is the parser object. CommonJS require also works.","wrong":"const lua2js = require('lua2js')","symbol":"lua2js","correct":"import lua2js from 'lua2js'"},{"note":"Named export for the parse function.","wrong":"const parse = require('lua2js').parse","symbol":"parse","correct":"import { parse } from 'lua2js'"},{"note":"Named export for the translate function.","wrong":"const lua2js = require('lua2js'); lua2js.translate(code)","symbol":"translate","correct":"import { translate } from 'lua2js'"}],"quickstart":{"code":"import lua2js from 'lua2js';\n\nconst luaCode = `\nfunction fib(n)\n    if n < 2 then\n        return n\n    else\n        return fib(n-1) + fib(n-2)\n    end\nend\nprint(fib(10))\n`;\n\nconst ast = lua2js.parse(luaCode);\nconst jsCode = lua2js.translate(ast);\nconsole.log(jsCode);\n// Output:\n// var fib = function(n) {\n//   if (n < 2) {\n//     return n;\n//   } else {\n//     return fib(n - 1) + fib(n - 2);\n//   }\n// };\n// console.log(fib(10));","lang":"typescript","description":"Parses a Lua Fibonacci function and translates it to JavaScript, demonstrating basic usage of parse and translate."},"warnings":[{"fix":"Implement missing functionality or avoid using those functions in Lua code.","message":"Lua standard library functions like string.format, pattern matching, coroutines, and debug are missing.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Use string or numeric keys only in table literals.","message":"Expression table keys (e.g., {[expr]=value}) are not supported.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Avoid long form strings with ]] sequences; use regular strings with escaped quotes if possible.","message":"Long form strings with internal ]] may cause parse errors even with [==[ syntax.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Consider alternative Lua-to-JS transpilers such as lua.js, moonscript, or fengari.","message":"The project has no recent releases since 2014 and may be abandoned.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Do not rely on _ENV or _G; assign globals directly.","message":"The global environment _ENV and _G are not supported; globals are defined as properties of the global object.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace {[expr]=value} with a string key or compute the value after table creation.","cause":"Using expression table keys which are unsupported.","error":"Error: Lua parse error at line 1: unexpected symbol near '['"},{"fix":"Include the lua2js runtime library (dist/lua2js.runtime.js) in your project.","cause":"Using luaCalls or luaOperators option without including the runtime support.","error":"TypeError: __lua is not defined"},{"fix":"Use import lua2js from 'lua2js' or require('lua2js') and then call lua2js.parse.","cause":"Importing the default export incorrectly (e.g., using require('lua2js').parse when default is the parser).","error":"lua2js.parse is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}