tstl-export-to-global
v1.0.1
Published
TypeScriptToLua plugin that transforms all exported variables to global declarations
Downloads
38
Readme
tstl-export-to-global
TypeScriptToLua plugin that transforms all exported variables in a given file to global declarations.
Can be used as an alternative to tstl-export-as-global. The benefits from switching to this plugin are as follows:
- Saves allocating one table
- Allows you to use
export const FOO = function()
instead ofexport function FOO()
if you prefer that syntax - All variables are transformed, not just functions
:exclamation: Use this and any code transformation plugin with caution. Mistakes are possible.
Example
local ____exports = {}
____exports.foo = 10
____exports.bar = function(self)
...
end
return ____exports
Becomes:
foo = 10
function bar(self)
...
end
Installation
Requires TSTL >= 1.22.0.
- Install this plugin
yarn add tstl-export-to-global -D
# or
npm install tstl-export-to-global --save-dev
Add
tstl-export-to-global
totstl.luaPlugins
intsconfig.json
Define
match
, which will only apply the transformation to files if their input (TypeScript file) path matches.
{
"tstl": {
"luaPlugins": [
+ {
+ "name": "tstl-export-to-global",
+ "match": ".*\\..*script.ts$"
+ }
],
}
}
License
CC0