Skip to content

Commit d91a2f6

Browse files
author
Naoaki Yamada
committed
Avoid using compilation.cache
1 parent 3f93c86 commit d91a2f6

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/index.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlug
77

88
export default function loader() {}
99

10-
const CACHE = {};
1110
const tapName = 'workerize-loader';
1211

1312
function compilationHook(compiler, handler) {
@@ -86,23 +85,9 @@ loader.pitch = function(request) {
8685
(new SingleEntryPlugin(this.context, `!!${path.resolve(__dirname, 'rpc-worker-loader.js')}!${request}`, 'main')).apply(worker.compiler);
8786

8887
const subCache = `subcache ${__dirname} ${request}`;
88+
const CACHE = this._compilation.getCache(subCache);
8989

9090
compilationHook(worker.compiler, (compilation, data) => {
91-
if (compilation.cache) {
92-
let cache;
93-
if (compilation.cache instanceof Map) {
94-
cache = compilation.cache.get(subCache);
95-
if (!cache) {
96-
cache = new Map();
97-
compilation.cache.set(subCache, cache);
98-
}
99-
}
100-
else if (!compilation.cache[subCache]) {
101-
cache = compilation.cache[subCache] = {};
102-
}
103-
104-
compilation.cache = cache;
105-
}
10691
parseHook(data, (parser, options) => {
10792
exportDeclarationHook(parser, expr => {
10893
let decl = expr.declaration || expr;

0 commit comments

Comments
 (0)