Skip to content

Commit

Permalink
refactor(@angular-devkit/build-angular): optimize bundle process cach…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
clydin authored and vikerman committed Sep 30, 2019
1 parent bdedff8 commit b3aaae0
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/angular_devkit/build_angular/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,23 +460,20 @@ export function buildWebpackBrowser(

// Attempt to get required cache entries
const cacheEntries = [];
let cached = cacheKeys.length > 0;
for (const key of cacheKeys) {
if (key) {
cacheEntries.push(await cacache.get.info(cacheDownlevelPath, key));
const entry = await cacache.get.info(cacheDownlevelPath, key);
if (!entry) {
cached = false;
break;
}
cacheEntries.push(entry);
} else {
cacheEntries.push(null);
}
}

// Check if required cache entries are present
let cached = cacheKeys.length > 0;
for (let i = 0; i < cacheKeys.length; ++i) {
if (cacheKeys[i] && !cacheEntries[i]) {
cached = false;
break;
}
}

// If all required cached entries are present, use the cached entries
// Otherwise process the files
// If SRI is enabled always process the runtime bundle
Expand Down

0 comments on commit b3aaae0

Please sign in to comment.