@gwigz/slua

Templates

Available project templates and optional extras

Single script

The single template produces the simplest possible project layout, one new-script.ts file at the project root that compiles to a single flat dist/new-script.slua via TSTL. Imports (including vendored modules) are bundled into that one output file, then tree-shaken by @gwigz/tstl-bundle-flatten so unused code is removed from the output.

my-project/
├── modules/          (when module extras are selected)
├── new-script.ts
├── package.json
└── tsconfig.json

Build once with the build script, or rebuild on every change with dev (which runs tstl --watch):

npm run build
npm run dev

Multi script

The multi template is for projects with multiple entry points (e.g. separate scripts for a coordinator, sender, and listener). It includes a custom build.ts script that compiles each entry point independently.

my-project/
├── src/
│   ├── coordinator/
│   │   └── index.ts
│   └── listener/
│       └── index.ts
├── build.ts
├── package.json
└── tsconfig.json

The scaffold ships one src/new-script/index.ts entry point; add more by listing them in the SCRIPTS array in build.ts.

build.ts uses the TSTL API directly to compile each entry point with its own output path. After bundling, @gwigz/tstl-bundle-flatten tree-shakes the flattened output, removing unused code (including vendored module functions, code pulled in through re-exports, and unused lualib functions).

Build once with the build script, or rebuild on every change with dev (which runs build.ts --watch):

npm run build
npm run dev

Optional extras

JSX templates (@gwigz/jsx-inline)

Adds support for JSX template syntax via @gwigz/jsx-inline, for building structured Lua strings out of TypeScript JSX.

Config, utilities, and yield modules

Vendors the selected @gwigz/slua-modules source into your project (src/modules/ in multi-script projects, modules/ in single-script ones). No package dependency is added, the copied TypeScript is yours to edit. Compile-time flags are pre-wired on the transpiler plugin config.

StyLua formatting

Adds StyLua so compiled .slua output can be auto-formatted, via a format script in single-script projects and as a build step in multi-script ones.

Linting (oxlint)

Adds oxlint with the @gwigz/slua-oxlint-config shared config, which catches TypeScript patterns that don't work in SLua or pull in large TSTL runtime helpers (delete, Map/Set, .splice(), async/await, browser/Node APIs, and more).

It also catches numbers and strings used directly as conditions, which behave differently in Lua (0 and "" are truthy there). That check is type-aware, so the lint script runs oxlint --type-aware.

Formatting (oxfmt)

Adds oxfmt for consistent TypeScript source formatting.

On this page