Skip to content

Commit f3b21a2

Browse files
TypeScript Botjakebailey
TypeScript Bot
andauthored
🤖 Pick PR #58931 (Defer creation of barebonesLibSourc...) into release-5.5 (#58933)
Co-authored-by: Jake Bailey <[email protected]>
1 parent 7b1620b commit f3b21a2

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)