Defer creation of barebonesLibSourceFile (#58931)

Co-authored-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
This commit is contained in:
Jake Bailey 2024-06-19 11:34:52 -07:00 committed by GitHub
parent c38569655b
commit 47bb090ded
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,6 +26,7 @@ import {
optionDeclarations,
parseCustomTypeOption,
ScriptTarget,
SourceFile,
toPath,
transpileOptionValueCompilerOptions,
} from "./_namespaces/ts.js";
@ -109,9 +110,11 @@ interface Symbol {
readonly [Symbol.toStringTag]: string;
}`;
const barebonesLibName = "lib.d.ts";
const barebonesLibSourceFile = createSourceFile(barebonesLibName, barebonesLibContent, { languageVersion: ScriptTarget.Latest });
let barebonesLibSourceFile: SourceFile | undefined;
function transpileWorker(input: string, transpileOptions: TranspileOptions, declaration?: boolean): TranspileOutput {
barebonesLibSourceFile ??= createSourceFile(barebonesLibName, barebonesLibContent, { languageVersion: ScriptTarget.Latest });
const diagnostics: Diagnostic[] = [];
const options: CompilerOptions = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {};