{"id":25815,"library":"jsx-lua-transpiler","title":"JSX Lua Transpiler","description":"A TypeScript library (v1.1.2) that transpiles JSX-like syntax into Lua tables. It parses JSX expressions embedded in Lua code and converts them to a structured table format with type, name, atts (attributes), and children fields. This enables writing HTML-like markup inside Lua, particularly useful for Lua-based UI frameworks or game engines. The package ships TypeScript declarations and requires TypeScript 5+ as a peer dependency. Compared to general Lua transpilers, it is focused specifically on JSX-to-Lua conversion with no overhead. The project is maintained by a single developer on GitHub.","status":"active","version":"1.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/ankushKun/jsx-lua-transpiler","tags":["javascript","jsx","lua","transpiler","typescript"],"install":[{"cmd":"npm install jsx-lua-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add jsx-lua-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add jsx-lua-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as peer dependency for TypeScript type definitions and compilation.","package":"typescript","optional":true}],"imports":[{"note":"The package is ESM-only (TypeScript source). Default export not available.","wrong":"const transpileLuaX = require('jsx-lua-transpiler')","symbol":"transpileLuaX","correct":"import { transpileLuaX } from 'jsx-lua-transpiler'"},{"note":"TranspileResult is a type, use 'import type' to avoid runtime import.","wrong":"import { TranspileResult } from 'jsx-lua-transpiler'","symbol":"TranspileResult","correct":"import type { TranspileResult } from 'jsx-lua-transpiler'"},{"note":"No default export; only named export exists.","wrong":"import transpileLuaX from 'jsx-lua-transpiler'","symbol":"default","correct":"import { transpileLuaX } from 'jsx-lua-transpiler'"}],"quickstart":{"code":"import { transpileLuaX } from 'jsx-lua-transpiler';\n\nconst luaCode = `\nlocal element = <div class=\"container\">\n    <h1>Hello World</h1>\n    <img src=\"image.jpg\" alt=\"An image\" />\n</div>\n\nprint(element)\n`;\n\nconst transpiled = transpileLuaX(luaCode);\nconsole.log(transpiled);\n// Output: {\n//   type: 'html', name: 'div', atts: { class: 'container' },\n//   children: [\n//     { type: 'html', name: 'h1', atts: {}, children: [{ type: 'text', text: 'Hello World' }] },\n//     { type: 'html', name: 'img', atts: { src: 'image.jpg', alt: 'An image' }, children: [] }\n//   ]\n// }","lang":"typescript","description":"Demonstrates converting JSX-like syntax within Lua code into a nested Lua table representation using transpileLuaX."},"warnings":[{"fix":"Update code expecting old format; adjust Lua code that processes the transpiled tables.","message":"v1.0.0 changed output table structure: children now always an array, not table with numeric indices.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure JSX is not inside a Lua string literal. Use raw code blocks.","message":"JSX must be written as literal in Lua string; strings containing JSX are not transpiled.","severity":"gotcha","affected_versions":">=1.1.2"},{"fix":"Always close self-closing tags with />.","message":"Self-closing tags (like <img />) require the trailing slash; otherwise parsed incorrectly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to v1.1.0+ and access output.code instead of plain string.","message":"transpileLuaX function behavior changed in v1.1.0: now returns an object with 'code' field.","severity":"deprecated","affected_versions":"<1.1.0"},{"fix":"Use attribute names without hyphens or wrap in quotes if needed.","message":"HTML tag attributes with hyphens (e.g., data-value) may not be recognized; use camelCase or quoted strings.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install typescript@^5' as a dev dependency.","cause":"Missing TypeScript peer dependency or not installed.","error":"Cannot find module 'jsx-lua-transpiler' or its corresponding type declarations"},{"fix":"Wrap JSX in a Lua string and pass to transpileLuaX.","cause":"Trying to use JSX outside of Lua code string assignment.","error":"Expected a assignment or function call and instead saw an expression"},{"fix":"Use 'import { transpileLuaX } from 'jsx-lua-transpiler''.","cause":"Importing default export instead of named export.","error":"TypeError: transpileLuaX is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}