Skip to content

TypeScriptToLua plugin that removes debugging expressions

License

Notifications You must be signed in to change notification settings

thinknathan/tstl-remove-debug

Repository files navigation

tstl-remove-debug

CI GitHub License

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.

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

Example

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

Becomes:

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

Installation

Requires TSTL >= 1.22.0.

  1. Install this plugin
yarn add tstl-remove-debug -D
# or
npm install tstl-remove-debug --save-dev
  1. Add tstl-remove-debug to tstl.luaPlugins in tsconfig.json
{
	"tstl": {
		"luaPlugins": [
+			{ "name": "tstl-remove-debug" }
		],
	}
}

License

CC0