Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thinknathan/tstl-export-rename
TypeScriptToLua plugin that renames the `___exports` variable
https://github.com/thinknathan/tstl-export-rename
lua tstl tstl-extension tstl-plugin typescript
Last synced: 6 days ago
JSON representation
TypeScriptToLua plugin that renames the `___exports` variable
- Host: GitHub
- URL: https://github.com/thinknathan/tstl-export-rename
- Owner: thinknathan
- License: cc0-1.0
- Created: 2024-01-07T20:48:06.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-11-01T11:55:37.000Z (6 days ago)
- Last Synced: 2024-11-01T12:29:03.540Z (6 days ago)
- Topics: lua, tstl, tstl-extension, tstl-plugin, typescript
- Language: TypeScript
- Homepage:
- Size: 857 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tstl-export-rename
[![CI](https://github.com/thinknathan/tstl-export-rename/actions/workflows/ci.yml/badge.svg)](https://github.com/thinknathan/tstl-export-rename/actions/workflows/ci.yml) ![GitHub License](https://img.shields.io/github/license/thinknathan/tstl-export-rename)
TypeScriptToLua plugin that renames the `___exports` variable for cosmetic reasons.
:exclamation: Use this and any code transformation plugin with caution. Mistakes are possible.
## Example
```lua
local ____exports = {}
____exports.foo = 10
____exports.bar = function(self)
...
end
return ____exports
```Becomes:
```lua
local M = {}
M.foo = 10
M.bar = function(self)
...
end
return M
```## Installation
Requires TSTL >= 1.22.0.
1. Install this plugin
```bash
yarn add tstl-export-rename -D
# or
npm install tstl-export-rename --save-dev
```2. Add `tstl-export-rename` to `tstl.luaPlugins` in `tsconfig.json`
3. Define `match`, which will only apply the transformation to files if their _output_ (Lua file) path matches.
4. Define `exportRename`, which will be used to replace `___exports`
```diff
{
"tstl": {
"luaPlugins": [
+ {
+ "name": "tstl-export-rename",
+ "match": ".*\\..*.lua$",
+ "exportRename": "M"
+ }
],
}
}
```## License
CC0