Skip to content

Commit 9c9be36

Browse files
refactor: code
1 parent 8d60fc9 commit 9c9be36

File tree

7 files changed

+251
-149
lines changed

7 files changed

+251
-149
lines changed

src/Webpack4Cache.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export default class Webpack4Cache {
1919
);
2020
}
2121

22-
async get(task, sources) {
23-
const weakOutput = this.weakCache.get(task.assetSource);
22+
async get(cacheData, sources) {
23+
const weakOutput = this.weakCache.get(cacheData.assetSource);
2424

2525
if (weakOutput) {
2626
return weakOutput;
@@ -32,12 +32,13 @@ export default class Webpack4Cache {
3232
}
3333

3434
// eslint-disable-next-line no-param-reassign
35-
task.cacheIdent = task.cacheIdent || serialize(task.cacheKeys);
35+
cacheData.cacheIdent =
36+
cacheData.cacheIdent || serialize(cacheData.cacheKeys);
3637

3738
let cachedResult;
3839

3940
try {
40-
cachedResult = await cacache.get(this.cache, task.cacheIdent);
41+
cachedResult = await cacache.get(this.cache, cacheData.cacheIdent);
4142
} catch (ignoreError) {
4243
// eslint-disable-next-line no-undefined
4344
return undefined;
@@ -63,17 +64,24 @@ export default class Webpack4Cache {
6364
return cachedResult;
6465
}
6566

66-
async store(task) {
67-
if (!this.weakCache.has(task.assetSource)) {
68-
this.weakCache.set(task.assetSource, task);
67+
async store(cacheData) {
68+
if (!this.weakCache.has(cacheData.assetSource)) {
69+
this.weakCache.set(cacheData.assetSource, cacheData);
6970
}
7071

7172
if (!this.cache) {
7273
// eslint-disable-next-line no-undefined
7374
return undefined;
7475
}
7576

76-
const { cacheIdent, css, assetName, map, input, inputSourceMap } = task;
77+
const {
78+
cacheIdent,
79+
css,
80+
assetName,
81+
map,
82+
input,
83+
inputSourceMap,
84+
} = cacheData;
7785

7886
return cacache.put(
7987
this.cache,

src/Webpack5Cache.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ export default class Cache {
44
this.cache = compilation.getCache('CssMinimizerWebpackPlugin');
55
}
66

7-
async get(task) {
7+
async get(cacheData) {
88
// eslint-disable-next-line no-param-reassign
9-
task.eTag = task.eTag || this.cache.getLazyHashedEtag(task.assetSource);
9+
cacheData.eTag =
10+
cacheData.eTag || this.cache.getLazyHashedEtag(cacheData.assetSource);
1011

11-
return this.cache.getPromise(task.assetName, task.eTag);
12+
return this.cache.getPromise(cacheData.assetName, cacheData.eTag);
1213
}
1314

14-
async store(task) {
15-
const { source, warnings } = task;
15+
async store(cacheData) {
16+
const { source, warnings } = cacheData;
1617

17-
return this.cache.storePromise(task.assetName, task.eTag, {
18+
return this.cache.storePromise(cacheData.assetName, cacheData.eTag, {
1819
source,
1920
warnings,
2021
});

0 commit comments

Comments
 (0)