Documentation
Shared runtime modules for SLua projects
Work in Progress
These modules are under active development and have not been battle-tested in production. APIs may change between releases.
@gwigz/slua-modules provides reusable runtime modules for
SLua projects. Each module is imported via a
subpath export and compiled to Lua through
TypeScript-to-Lua. Unused code is stripped
at compile time via @define flags.
Install
npm install @gwigz/slua-modulesTSTL configuration
TSTL's luaBundle resolver cannot resolve TypeScript source from node_modules
directly. Add paths to your tsconfig so TSTL can find the module source:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@gwigz/slua-modules/*": ["node_modules/@gwigz/slua-modules/src/*/index.ts"],
},
},
}Compile-time flags
Some modules use compile-time flags to strip unused code from the Lua output.
Flags are set via the define option on @gwigz/slua-tstl-plugin in your
tsconfig. When a flag is false (or omitted), the guarded code is removed
entirely by dead code elimination.
{
"tstl": {
"luaPlugins": [
{
"name": "@gwigz/slua-tstl-plugin",
"define": {
"CONFIG_YAML_PARSER": true,
"YIELD_DATASERVER_AGENT": true,
"YIELD_HTTP": true,
},
},
],
},
}Only enable the flags you need, omitted flags default to false and their
code is stripped. See each module's documentation for the available flags.