From 1e8fd70c6f1bf2735474fcac0f109bd2bafa980e Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:58:19 -0400 Subject: [PATCH] fix(@angular/build): show JavaScript cache store initialization warning If the persistent cache store for the JavaScript transformations fails to initialize, a warning will now be shown to better explain the outcome and to allow the build to continue. The build will still complete without the cache but may be slower to finish. --- .../tools/esbuild/angular/compiler-plugin.ts | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 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 5fb4474557d6..24d3d7f0bd52 100644 --- a/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts +++ b/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts @@ -65,10 +65,24 @@ export function createCompilerPlugin( // Webcontainers currently do not support this persistent cache store. let cacheStore: import('../lmdb-cache-store').LmbdCacheStore | undefined; if (pluginOptions.sourceFileCache?.persistentCachePath && !process.versions.webcontainer) { - const { LmbdCacheStore } = await import('../lmdb-cache-store'); - cacheStore = new LmbdCacheStore( - path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db'), - ); + try { + const { LmbdCacheStore } = await import('../lmdb-cache-store'); + cacheStore = new LmbdCacheStore( + path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db'), + ); + } catch (e) { + setupWarnings.push({ + text: 'Unable to initialize JavaScript cache storage.', + location: null, + notes: [ + // Only show first line of lmdb load error which has platform support listed + { text: (e as Error)?.message.split('\n')[0] ?? `${e}` }, + { + text: 'This will not affect the build output content but may result in slower builds.', + }, + ], + }); + } } const javascriptTransformer = new JavaScriptTransformer( {