Registry / serialization / jsx-lua-transpiler

jsx-lua-transpiler

JSON →
library1.1.2jsnpmunverified

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.

npm install jsx-lua-transpiler
INSTALL
IMPORT
SIG · JSX-LUA-TRANSPILER
J
jsx-lua-transpiler
serializationjavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

transpileLuaX
import { transpileLuaX } from 'jsx-lua-transpiler'
const transpileLuaX = require('jsx-lua-transpiler')
The package is ESM-only (TypeScript source). Default export not available.
TranspileResult
import type { TranspileResult } from 'jsx-lua-transpiler'
import { TranspileResult } from 'jsx-lua-transpiler'
TranspileResult is a type, use 'import type' to avoid runtime import.
default
import { transpileLuaX } from 'jsx-lua-transpiler'
import transpileLuaX from 'jsx-lua-transpiler'
No default export; only named export exists.

Demonstrates converting JSX-like syntax within Lua code into a nested Lua table representation using transpileLuaX.

import { transpileLuaX } from 'jsx-lua-transpiler'; const luaCode = ` local element = <div class="container"> <h1>Hello World</h1> <img src="image.jpg" alt="An image" /> </div> print(element) `; const transpiled = transpileLuaX(luaCode); console.log(transpiled); // Output: { // type: 'html', name: 'div', atts: { class: 'container' }, // children: [ // { type: 'html', name: 'h1', atts: {}, children: [{ type: 'text', text: 'Hello World' }] }, // { type: 'html', name: 'img', atts: { src: 'image.jpg', alt: 'An image' }, children: [] } // ] // }
Debug
Known issues
breakingv1.0.0 changed output table structure: children now always an array, not table with numeric indices.
fix
Update code expecting old format; adjust Lua code that processes the transpiled tables.
affects: >=1.0.0
gotchaJSX must be written as literal in Lua string; strings containing JSX are not transpiled.
fix
Ensure JSX is not inside a Lua string literal. Use raw code blocks.
affects: >=1.1.2
gotchaSelf-closing tags (like <img />) require the trailing slash; otherwise parsed incorrectly.
fix
Always close self-closing tags with />.
affects: >=1.0.0
deprecatedtranspileLuaX function behavior changed in v1.1.0: now returns an object with 'code' field.
fix
Update to v1.1.0+ and access output.code instead of plain string.
affects: <1.1.0
gotchaHTML tag attributes with hyphens (e.g., data-value) may not be recognized; use camelCase or quoted strings.
fix
Use attribute names without hyphens or wrap in quotes if needed.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'jsx-lua-transpiler' or its corresponding type declarations
Missing TypeScript peer dependency or not installed.
fix
Run 'npm install typescript@^5' as a dev dependency.
Expected a assignment or function call and instead saw an expression
Trying to use JSX outside of Lua code string assignment.
fix
Wrap JSX in a Lua string and pass to transpileLuaX.
TypeError: transpileLuaX is not a function
Importing default export instead of named export.
fix
Use 'import { transpileLuaX } from 'jsx-lua-transpiler''.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
typescriptoptionalRequired as peer dependency for TypeScript type definitions and compilation.
Agent activity
6 hits · last 30 days
node
6
Resources
jsx-lua-transpiler — npm install jsx-lua-transpiler · libregistry