From 3760a897aa792ea1015fad146011af2d004a88bf Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:48:07 +0000 Subject: [PATCH] Merge 8dfa91296cc58de6b72caefdc02de7f6869e9bd8 into c38569655bb151ec351c27032fbd3ef43b8856ba --- 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 ccf8396247ca8..86622ea3e3528 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) : {};