Skip to content
Merged
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
19 changes: 15 additions & 4 deletions src/Webpack4Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,23 @@ export default class Webpack4Cache {
// eslint-disable-next-line no-param-reassign
task.cacheIdent = task.cacheIdent || serialize(task.cacheKeys);

const { data } = await cacache.get(this.cacheDir, task.cacheIdent);
let cachedResult;

return JSON.parse(data);
try {
cachedResult = await cacache.get(this.cacheDir, task.cacheIdent);
} catch (ignoreError) {
// eslint-disable-next-line no-undefined
return undefined;
}

return JSON.parse(cachedResult.data);
}

async store(task, data) {
return cacache.put(this.cacheDir, task.cacheIdent, JSON.stringify(data));
async store(task) {
return cacache.put(
this.cacheDir,
task.cacheIdent,
JSON.stringify(task.output)
);
}
}
12 changes: 4 additions & 8 deletions src/Webpack5Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ export default class Cache {

async get(task) {
// eslint-disable-next-line no-param-reassign
task.cacheIdent = task.cacheIdent || `${task.name}`;
task.eTag = task.eTag || this.cache.getLazyHashedEtag(task.assetSource);

// eslint-disable-next-line no-param-reassign
task.cacheETag =
task.cacheETag || this.cache.getLazyHashedEtag(task.assetSource);

return this.cache.getPromise(task.cacheIdent, task.cacheETag);
return this.cache.getPromise(task.assetName, task.eTag);
}

async store(task, data) {
return this.cache.storePromise(task.cacheIdent, task.cacheETag, data);
async store(task) {
return this.cache.storePromise(task.assetName, task.eTag, task.output);
}
}
Loading