Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/angular/build/src/tools/esbuild/load-result-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { OnLoadResult, PluginBuild } from 'esbuild';
import { normalize } from 'node:path';

export interface LoadResultCache {
get(path: string): OnLoadResult | undefined;
get(path: string): OnLoadResult | Promise<OnLoadResult | undefined> | undefined;
put(path: string, result: OnLoadResult): Promise<void>;
readonly watchFiles: ReadonlyArray<string>;
}
Expand All @@ -25,7 +25,7 @@ export function createCachedLoad(

return async (args) => {
const loadCacheKey = `${args.namespace}:${args.path}`;
let result: OnLoadResult | null | undefined = cache.get(loadCacheKey);
let result: OnLoadResult | null | undefined = await cache.get(loadCacheKey);

if (result === undefined) {
result = await callback(args);
Expand All @@ -35,7 +35,9 @@ export function createCachedLoad(
// Ensure requested path is included if it was a resolved file
if (args.namespace === 'file') {
result.watchFiles ??= [];
result.watchFiles.push(args.path);
if (!result.watchFiles.includes(args.path)) {
result.watchFiles.push(args.path);
}
}
await cache.put(loadCacheKey, result);
}
Expand Down
Loading
Loading