Skip to content

Commit 190f80c

Browse files
clydinvikerman
authored andcommitted
refactor(@angular-devkit/build-angular): optimize bundle process cache detection
This causes the cache checking to stop on the first miss since all required entries must be present for a bundle to be considered cached.
1 parent dd2a694 commit 190f80c

File tree

1 file changed

+7
-10
lines changed
  • packages/angular_devkit/build_angular/src/browser

1 file changed

+7
-10
lines changed

packages/angular_devkit/build_angular/src/browser/index.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,23 +449,20 @@ export function buildWebpackBrowser(
449449

450450
// Attempt to get required cache entries
451451
const cacheEntries = [];
452+
let cached = cacheKeys.length > 0;
452453
for (const key of cacheKeys) {
453454
if (key) {
454-
cacheEntries.push(await cacache.get.info(cacheDownlevelPath, key));
455+
const entry = await cacache.get.info(cacheDownlevelPath, key);
456+
if (!entry) {
457+
cached = false;
458+
break;
459+
}
460+
cacheEntries.push(entry);
455461
} else {
456462
cacheEntries.push(null);
457463
}
458464
}
459465

460-
// Check if required cache entries are present
461-
let cached = cacheKeys.length > 0;
462-
for (let i = 0; i < cacheKeys.length; ++i) {
463-
if (cacheKeys[i] && !cacheEntries[i]) {
464-
cached = false;
465-
break;
466-
}
467-
}
468-
469466
// If all required cached entries are present, use the cached entries
470467
// Otherwise process the files
471468
// If SRI is enabled always process the runtime bundle

0 commit comments

Comments
 (0)