You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `beforeTransform` function on plugins is called after gathering the TypeScript program and compiler options, but before any transformation to Lua is done.
115
+
116
+
It can be used to set up the plugin
117
+
118
+
```ts
119
+
import*astsfrom"typescript";
120
+
import*aststlfrom"typescript-to-lua";
121
+
122
+
classPluginimplementststl.Plugin {
123
+
public beforeTransform(program:ts.Program, options:tstl.CompilerOptions, emitHost:EmitHost) {
124
+
console.log("starting transformation of program", program, "with options", options);
125
+
}
126
+
}
127
+
128
+
const plugin =newPlugin();
129
+
exportdefaultplugin;
130
+
```
131
+
132
+
### `afterPrint`
133
+
134
+
The `afterPrint` function is called _after_ tstl has finished its work, except for resolving dependencies and calculating output paths. You can use this to modify the list of output files and do direct string modifications to them.
|`luaTarget`|`"JIT"`, `"5.3"`, `"5.2"`, `"5.1"`, `"universal"` (default: `"universal"`) | Specifies the Lua version you want to generate code for. Choosing `universal` makes TypeScriptToLua generate code compatible with all supported Lua targets. |
29
-
|`noImplicitSelf`|`true`, `false` (default: `false`) | If true, treats all project files as if they were prefixed with<br />`/** @noSelfInFile **/`. |
30
-
|`noHeader`|`true`, `false` (default: `false`) | Set this to true if you don't want to include our header in the output. |
31
-
|`luaLibImport`|`"inline"`, `"require"`, `"always"`, `"none"` (default: `"require"`) | We polyfill certain JavaScript features with Lua functions, this option specifies how these functions are imported into the Lua output. |
32
-
|`sourceMapTraceback`|`true`, `false` (default: `false`) | Overrides Lua's `debug.traceback` to apply sourcemaps to Lua stacktraces. This will make error messages point to your original TypeScript code instead of the generated Lua. |
33
-
|`luaBundle`| File path (relative to the `tsconfig.json`) | Will bundle all output lua files into a single bundle file. Requires **luaBundleEntry** to be set! |
34
-
|`luaBundleEntry`| File path (relative to the `tsconfig.json`) | This should be the name/path of the TS file in your project that will serve as entry point to the bundled code. |
35
-
|`luaPlugins`|`Array<{ name: string; import?: string }>`| List of [TypeScriptToLua plugins](api/plugins.md). |
36
-
|`buildMode`|`"default"`, `"library"` (default: `"library"`) | Use `buildMode: "library"` to build [publishable library packages](publishing-modules.md). |
37
-
|`tstlVerbose`|`true`, `false` (default: `false`) | Output additional logging when performing a tstl build, to help diagnose issues. |
38
-
|`noResolvePaths`|`Array<string>`| An array of require paths that will **NOT** be resolved. For example `["require1", "sub.require2"]` will stop tstl from trying to resolve Lua sources for `require("require1")` and `require("sub.require2")`. |
|`luaTarget`|`"JIT"`, `"5.3"`, `"5.2"`, `"5.1"`, `"universal"` (default: `"universal"`) | Specifies the Lua version you want to generate code for. Choosing `universal` makes TypeScriptToLua generate code compatible with all supported Lua targets. |
31
+
|`noImplicitSelf`|`true`, `false` (default: `false`) | If true, treats all project files as if they were prefixed with<br />`/** @noSelfInFile **/`. |
32
+
|`noHeader`|`true`, `false` (default: `false`) | Set this to true if you don't want to include our header in the output. |
33
+
|`luaLibImport`|`"inline"`, `"require"`, `"none"` (default: `"require"`) | We polyfill certain JavaScript features with Lua functions, this option specifies how these functions are imported into the Lua output. `"inline"`: Inline used functions in code; `"require"`: Require full lualib bundle if used in file. `"none"`: Never require/inline any lualib features. |
34
+
|`sourceMapTraceback`|`true`, `false` (default: `false`) | Overrides Lua's `debug.traceback` to apply sourcemaps to Lua stacktraces. This will make error messages point to your original TypeScript code instead of the generated Lua. |
35
+
|`luaBundle`| File path (relative to the `tsconfig.json`) | Will bundle all output lua files into a single bundle file. Requires **luaBundleEntry** to be set! |
36
+
|`luaBundleEntry`| File path (relative to the `tsconfig.json`) | This should be the name/path of the TS file in your project that will serve as entry point to the bundled code. |
37
+
|`luaPlugins`|`Array<{ name: string; import?: string }>`| List of [TypeScriptToLua plugins](api/plugins.md). |
38
+
|`tstlVerbose`|`true`, `false` (default: `false`) | Output additional logging when performing a tstl build, to help diagnose issues. |
39
+
|`noResolvePaths`|`Array<string>`| An array of require paths that will **NOT** be resolved. For example `["require1", "sub.require2"]` will stop tstl from trying to resolve Lua sources for `require("require1")` and `require("sub.require2")`. |
0 commit comments