Skip to content

TypeScriptToLua Plugins

Plugins are opt-in TypeScriptToLua build transforms. Enable only the plugins your project uses. An XRF build that needs every SDK transformation uses this order:

jsonc
{
  "tstl": {
    "luaPlugins": [
      { "name": "xray16/plugins/luabind" },
      { "name": "xray16/plugins/strip" },
      { "name": "xray16/plugins/macros" },
      { "name": "xray16/plugins/optimize" },
      { "name": "xray16/plugins/inline" },
      { "name": "xray16/plugins/libcompile" },
      { "name": "xray16/plugins/tracy" },
    ],
  },
}
PluginUse it when you need
luabindEmit class("Name") declarations for @LuabindClass() classes.
stripRemove Lua logger calls and imports for engine-only typedef modules.
macrosFold filename, dirname, nil-check, cast, and build-header helpers.
optimizeRewrite returned ternaries into direct Lua if / else returns.
inlineInline tagged constants, functions, and $inline / $noInline hints.
libcompileEmit xray16/lib source as a flat xray_bundle module.
tracyInject Tracy profiler zones.

When their config fields are unset, strip.luaLogger falls back to XR_NO_LUA_LOGS=true or --no-lua-logs, and tracy.enabled falls back to XR_INJECT_TRACY_ZONES=true or --inject-tracy-zones.

Luabind classes

Classes that extend C++ objects need luabind registration rather than default TypeScriptToLua prototype output:

ts
import { LuabindClass, object_binder } from "xray16";

@LuabindClass()
export class ActorBinder extends object_binder {
  public override net_spawn(object: unknown): boolean {
    return super.net_spawn(object);
  }
}

See the luabind plugin page for constructor and inheritance rules.