Skip to content

Commit 47bb090

Browse files
Defer creation of barebonesLibSourceFile (#58931)
Co-authored-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
1 parent c385696 commit 47bb090

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/services/transpile.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
optionDeclarations,
2727
parseCustomTypeOption,
2828
ScriptTarget,
29+
SourceFile,
2930
toPath,
3031
transpileOptionValueCompilerOptions,
3132
} from "./_namespaces/ts.js";
@@ -109,9 +110,11 @@ interface Symbol {
109110
readonly [Symbol.toStringTag]: string;
110111
}`;
111112
const barebonesLibName = "lib.d.ts";
112-
const barebonesLibSourceFile = createSourceFile(barebonesLibName, barebonesLibContent, { languageVersion: ScriptTarget.Latest });
113+
let barebonesLibSourceFile: SourceFile | undefined;
113114

114115
function transpileWorker(input: string, transpileOptions: TranspileOptions, declaration?: boolean): TranspileOutput {
116+
barebonesLibSourceFile ??= createSourceFile(barebonesLibName, barebonesLibContent, { languageVersion: ScriptTarget.Latest });
117+
115118
const diagnostics: Diagnostic[] = [];
116119

117120
const options: CompilerOptions = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {};

0 commit comments

Comments
 (0)