Skip to content

Commit 56d8399

Browse files
committed
Added option to suppress emitting lualib
1 parent 783b632 commit 56d8399

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

src/CompilerOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface TypeScriptToLuaOptions {
4747
lua51AllowTryCatchInAsyncAwait?: boolean;
4848
measurePerformance?: boolean;
4949
luaLibName?: string;
50+
luaLibEmit?: boolean;
5051
}
5152

5253
export type CompilerOptions = OmitIndexSignature<ts.CompilerOptions> &

src/cli/parse.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export const optionDeclarations: CommandLineOption[] = [
5656
description: "The name of the file to store Lua library features in.",
5757
type: "string",
5858
},
59+
{
60+
name: "luaLibEmit",
61+
description: "Whether the Lua library file is emitted with the code. Only effective when luaLibImport is require.",
62+
type: "boolean",
63+
},
5964
{
6065
name: "luaTarget",
6166
aliases: ["lt"],

src/transpilation/transpiler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ export class Transpiler {
132132
console.log("Including lualib bundle");
133133
}
134134
// Add lualib bundle to source dir 'virtually', will be moved to correct output dir in emitPlan
135-
const fileName = normalizeSlashes(path.resolve(getSourceDir(program), (options.luaLibName ?? "lualib_bundle") + ".lua"));
136-
const code = this.getLuaLibBundleContent(options, resolutionResult.resolvedFiles);
137-
resolutionResult.resolvedFiles.unshift({ fileName, code });
135+
if (options.luaLibEmit !== false) {
136+
const fileName = normalizeSlashes(path.resolve(getSourceDir(program), (options.luaLibName ?? "lualib_bundle") + ".lua"));
137+
const code = this.getLuaLibBundleContent(options, resolutionResult.resolvedFiles);
138+
resolutionResult.resolvedFiles.unshift({ fileName, code });
139+
}
138140
}
139141

140142
let emitPlan: EmitFile[];

tsconfig-schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
"type": "string",
5252
"default": "lualib_bundle"
5353
},
54+
"luaLibEmit": {
55+
"description": "Whether the Lua library file is emitted with the code. Only effective when luaLibImport is require.",
56+
"type": "boolean",
57+
"default": true
58+
},
5459
"luaTarget": {
5560
"description": "Specifies the Lua version you want to generate code for.",
5661
"type": "string",

0 commit comments

Comments
 (0)