From f3b21a2033206e585b2b7b18622104f09eb87f2e Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 19 Jun 2024 14:35:58 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Pick=20PR=20#58931=20(Defer=20cr?= =?UTF-8?q?eation=20of=20barebonesLibSourc...)=20into=20release-5.5=20(#58?= =?UTF-8?q?933)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com> --- src/services/transpile.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/transpile.ts b/src/services/transpile.ts index ccf8396247c..86622ea3e35 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -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) : {};