laux-compiler
raw JSON →LAUX is a superset of Lua that transpiles to standard Lua, adding syntax sugar such as fat/thin arrow functions, decorators, real-time type checking, import/export statements, spread operators, and null-conditional operators. This package (v1.6.0) is a fork of the now-dead LAU project by Metamist, aiming to revitalize it with syntax and functionality changes. It is published on npm and used via a CLI tool (lauxc) after global installation. Release cadence is irregular; the package is actively maintained by the fork author. Key differentiators include workspace configuration files for merging multiple input files, decorators for function mutation, and compile-time type checking (with a performance caveat). It is primarily used in the Garry's Mod Lua ecosystem.
Common errors
error Error: Cannot find module 'laux-compiler' ↓
error lauxc: command not found ↓
error Error: lauxconfig.json not found ↓
error TypeError: ... is not a function ↓
Warnings
gotcha Real time type checking should not be used in performance-critical code that runs every frame (e.g., in Garry's Mod hook callbacks). ↓
gotcha Only one decorator per function is allowed. To combine multiple, you must create a single wrapper decorator. ↓
gotcha Arrow functions with thin arrow (->) automatically add 'self' as the first argument, which can lead to unexpected parameters if not accounted for. ↓
deprecated The original LAU project is dead; this fork may have incompatible syntax changes. Check the fork's documentation for differences. ↓
Install
npm install laux-compiler yarn add laux-compiler pnpm add laux-compiler Imports
- CLI wrong
Using require('laux-compiler') in Node.js codecorrectnpm i -g laux-compiler && lauxc watch ./laux ./lua - Workspace config wrong
Running lauxc without workspace config expecting default behaviorcorrectCreate lauxconfig.json in root folder and run lauxc workspace - Release mode wrong
Using -r flag without workspace configcorrectlauxc workspace -r
Quickstart
npm i -g laux-compiler
mkdir myapp && cd myapp
mkdir laux lua
echo 'local greet = (name) => print("Hello, " .. name) end' > laux/hello.laux
lauxc watch ./laux ./lua
cat lua/hello.lua