From 706423acad2c431c4125166d078dbad804719d95 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 22 May 2024 16:13:58 -0400 Subject: [PATCH] fix(@angular/build): only import persistent cache store with active caching To avoid loading and initializing the underlying persistent cache store when caching is disabled, the lmdb-based cache will now only be imported when caching is enabled. (cherry picked from commit 1fc10ecfeae5c32385ca723c8afa43b33fae7375) --- .../build/src/tools/esbuild/angular/compiler-plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts b/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts index 32a138eb7768..060931de8200 100644 --- a/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts +++ b/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts @@ -19,7 +19,6 @@ import assert from 'node:assert'; import * as path from 'node:path'; import { maxWorkers, useTypeChecking } from '../../../utils/environment-options'; import { JavaScriptTransformer } from '../javascript-transformer'; -import { LmbdCacheStore } from '../lmdb-cache-store'; import { LoadResultCache, createCachedLoad } from '../load-result-cache'; import { logCumulativeDurations, profileAsync, resetCumulativeDurations } from '../profiling'; import { BundleStylesheetOptions } from '../stylesheets/bundle-options'; @@ -63,8 +62,9 @@ export function createCompilerPlugin( const preserveSymlinks = build.initialOptions.preserveSymlinks; // Initialize a worker pool for JavaScript transformations - let cacheStore: LmbdCacheStore | undefined; + let cacheStore: import('../lmdb-cache-store').LmbdCacheStore | undefined; if (pluginOptions.sourceFileCache?.persistentCachePath) { + const { LmbdCacheStore } = await import('../lmdb-cache-store'); cacheStore = new LmbdCacheStore( path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db'), );