Skip to content

Commit 8e8aa39

Browse files
committed
Move lualibCompilation option out of public api
1 parent c5e3e9e commit 8e8aa39

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

build-lualib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ const path = require("path");
33
const tstl = require("./src");
44

55
const configFileName = path.resolve(__dirname, "src/lualib/tsconfig.json");
6-
const { diagnostics } = tstl.transpileProject(configFileName);
6+
const { diagnostics } = tstl.transpileLuaLibProject(configFileName);
77
diagnostics.forEach(tstl.createDiagnosticReporter(true));

src/cli/information.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export function getHelpString(): string {
1919

2020
result += "Options:\n";
2121
for (const option of optionDeclarations) {
22-
if (option.internal) continue;
2322
const aliasStrings = (option.aliases ?? []).map(a => "-" + a);
2423
const optionString = [...aliasStrings, "--" + option.name].join("|");
2524

src/cli/parse.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ interface CommandLineOptionBase {
1010
name: string;
1111
aliases?: string[];
1212
description: string;
13-
internal?: boolean;
1413
}
1514

1615
interface CommandLineOptionOfEnum extends CommandLineOptionBase {
@@ -84,12 +83,6 @@ export const optionDeclarations: CommandLineOption[] = [
8483
description: "An array of paths that tstl should not resolve and keep as-is.",
8584
type: "array",
8685
},
87-
{
88-
name: "luaLibCompilation",
89-
description: "Internal. Specifies if this project is lualib source.",
90-
type: "boolean",
91-
internal: true,
92-
},
9386
];
9487

9588
export function updateParsedConfigFile(parsedConfigFile: ts.ParsedCommandLine): ParsedCommandLine {
@@ -110,7 +103,7 @@ export function updateParsedConfigFile(parsedConfigFile: ts.ParsedCommandLine):
110103

111104
for (const [name, rawValue] of Object.entries(parsedConfigFile.raw.tstl)) {
112105
const option = optionDeclarations.find(option => option.name === name);
113-
if (!option && option !== "lualibCompilation") {
106+
if (!option) {
114107
parsedConfigFile.errors.push(cliDiagnostics.unknownCompilerOption(name));
115108
continue;
116109
}

src/lualib/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
},
1111
"tstl": {
1212
"luaLibImport": "none",
13-
"noHeader": true,
14-
"luaLibCompilation": true
13+
"noHeader": true
1514
}
1615
}

src/transpilation/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ export function transpileProject(
4040
return transpileFiles(parseResult.fileNames, parseResult.options, writeFile);
4141
}
4242

43+
/** @internal */
44+
export function transpileLuaLibProject(configFileName: string): EmitResult {
45+
const parseResult = parseConfigFileWithSystem(configFileName);
46+
if (parseResult.errors.length > 0) {
47+
return { diagnostics: parseResult.errors, emitSkipped: true };
48+
}
49+
parseResult.options.luaLibCompilation = true;
50+
51+
return transpileFiles(parseResult.fileNames, parseResult.options);
52+
}
53+
4354
const libCache: { [key: string]: ts.SourceFile } = {};
4455

4556
/** @internal */

0 commit comments

Comments
 (0)