Skip to content

Commit 7e47643

Browse files
committed
Documentation for afterEmit plugins
1 parent 5f1ddce commit 7e47643

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/api/plugins.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,25 @@ const plugin: tstl.Plugin = {
174174
export default plugin;
175175
```
176176

177+
### `afterEmit`
178+
179+
The `afterEmit` function is called after all output files have been written to disk. This might be useful if you need to somehow post-process the output Lua, for example by feeding it to a Lua minifier.
180+
181+
```ts
182+
import * as ts from "typescript";
183+
import * as tstl from "typescript-to-lua";
184+
185+
const plugin: tstl.Plugin = {
186+
afterEmit(program: ts.Program, options: tstl.CompilerOptions, emitHost: tstl.EmitHost, result: tstl.EmitFile[]) {
187+
for (const emittedFile of result) {
188+
console.log(`Emitted file ${emittedFile.outputPath}`);
189+
}
190+
},
191+
};
192+
193+
export default plugin;
194+
```
195+
177196
### `moduleResolution`
178197

179198
You can use the `moduleResolution` function to modify how the tstl module resolution works. It provides you with the require path, the file requiring that module, the tsconfig options used to compile the project, and the tstl EmitHost.

0 commit comments

Comments
 (0)