Skip to content

TypeScriptToLua plugin that renames the `___exports` variable

License

Notifications You must be signed in to change notification settings

thinknathan/tstl-export-rename

Repository files navigation

tstl-export-rename

CI GitHub License

TypeScriptToLua plugin that renames the ___exports variable for cosmetic reasons.

❗ 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:

local M = {}
M.foo = 10
M.bar = function(self)
	...
end
return M

Installation

Requires TSTL >= 1.22.0.

  1. Install this plugin
yarn add tstl-export-rename -D
# or
npm install tstl-export-rename --save-dev
  1. Add tstl-export-rename to tstl.luaPlugins in tsconfig.json

  2. Define match, which will only apply the transformation to files if their output (Lua file) path matches.

  3. Define exportRename, which will be used to replace ___exports

{
	"tstl": {
		"luaPlugins": [
+			{
+				"name": "tstl-export-rename",
+				"match": ".*\\..*.lua$",
+				"exportRename": "M"
+			}
		],
	}
}

License

CC0