Skip to content

Commit 1e8fd70

Browse files
committed
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.
1 parent 1a481c5 commit 1e8fd70

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,24 @@ export function createCompilerPlugin(
6565
// Webcontainers currently do not support this persistent cache store.
6666
let cacheStore: import('../lmdb-cache-store').LmbdCacheStore | undefined;
6767
if (pluginOptions.sourceFileCache?.persistentCachePath && !process.versions.webcontainer) {
68-
const { LmbdCacheStore } = await import('../lmdb-cache-store');
69-
cacheStore = new LmbdCacheStore(
70-
path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db'),
71-
);
68+
try {
69+
const { LmbdCacheStore } = await import('../lmdb-cache-store');
70+
cacheStore = new LmbdCacheStore(
71+
path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db'),
72+
);
73+
} catch (e) {
74+
setupWarnings.push({
75+
text: 'Unable to initialize JavaScript cache storage.',
76+
location: null,
77+
notes: [
78+
// Only show first line of lmdb load error which has platform support listed
79+
{ text: (e as Error)?.message.split('\n')[0] ?? `${e}` },
80+
{
81+
text: 'This will not affect the build output content but may result in slower builds.',
82+
},
83+
],
84+
});
85+
}
7286
}
7387
const javascriptTransformer = new JavaScriptTransformer(
7488
{

0 commit comments

Comments
 (0)