An open API service indexing awesome lists of open source software.

https://github.com/thinknathan/tstl-remove-debug

TypeScriptToLua plugin that removes debugging expressions
https://github.com/thinknathan/tstl-remove-debug

code-cleaner lua tstl tstl-extension tstl-plugin typescript

Last synced: 6 months ago
JSON representation

TypeScriptToLua plugin that removes debugging expressions

Awesome Lists containing this project

README

          

# tstl-remove-debug

[![CI](https://github.com/thinknathan/tstl-remove-debug/actions/workflows/ci.yml/badge.svg)](https://github.com/thinknathan/tstl-remove-debug/actions/workflows/ci.yml) ![GitHub License](https://img.shields.io/github/license/thinknathan/tstl-remove-debug)

TypeScriptToLua plugin that strips calls to `print`, `pprint`, `assert`, and any functions attached to `profiler` and `debug`. Also replaces the statement `sys.get_engine_info().is_debug` with `false`.

The purpose is to reduce code size for production builds.

:exclamation: Use this and any code transformation plugin with caution. Mistakes are possible.

## Example

```ts
print(foo);
pprint(foo);
assert(foo === '');
profiler.start();
debug.draw_text('');
const is_debug = sys.get_engine_info().is_debug;
```

Becomes:

```lua
-- (This space intentionally left blank)
local is_debug = false
```

## Installation

Requires TSTL >= 1.22.0.

1. Install this plugin

```bash
yarn add tstl-remove-debug -D
# or
npm install tstl-remove-debug --save-dev
```

2. Add `tstl-remove-debug` to `tstl.luaPlugins` in `tsconfig.json`

```diff
{
"tstl": {
"luaPlugins": [
+ { "name": "tstl-remove-debug" }
],
}
}
```

## License

CC0