Skip to content

Commit

Permalink
fix(@angular/build): show JavaScript cache store initialization warning
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
clydin committed Jun 21, 2024
1 parent 1a481c5 commit 1e8fd70
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit 1e8fd70

Please sign in to comment.