laux-compiler

raw JSON →
1.6.0 verified Fri May 01 auth: no javascript

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.

error Error: Cannot find module 'laux-compiler'
cause Package not installed globally or locally.
fix
Run 'npm i -g laux-compiler' to install globally.
error lauxc: command not found
cause Global npm binaries not in PATH.
fix
Ensure npm global bin directory is in your PATH, or run using 'npx lauxc'.
error Error: lauxconfig.json not found
cause Running 'lauxc workspace' without config file in current directory.
fix
Create a 'lauxconfig.json' file in the root folder of your project.
error TypeError: ... is not a function
cause Using real-time type checking on a non-function or mismatched type annotation.
fix
Ensure type annotations match actual usage; disable type checking in production if not needed.
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).
fix Use type checking only for development or non-hot paths, or disable it in production builds.
gotcha Only one decorator per function is allowed. To combine multiple, you must create a single wrapper decorator.
fix Define a decorator that internally chains multiple behaviors.
gotcha Arrow functions with thin arrow (->) automatically add 'self' as the first argument, which can lead to unexpected parameters if not accounted for.
fix Use fat arrow (=>) if explicit 'self' is not desired, or ensure the function signature accounts for 'self'.
deprecated The original LAU project is dead; this fork may have incompatible syntax changes. Check the fork's documentation for differences.
fix Refer to laux-compiler docs instead of LAU docs.
npm install laux-compiler
yarn add laux-compiler
pnpm add laux-compiler

Installs the CLI globally, creates input/output directories, writes a LAUX file with a fat arrow function, transpiles it, and prints the resulting Lua code.

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