forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebWorkerHotUpdateChunkTemplatePlugin.js
More file actions
28 lines (26 loc) · 1.15 KB
/
WebWorkerHotUpdateChunkTemplatePlugin.js
File metadata and controls
28 lines (26 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const ConcatSource = require("webpack-sources").ConcatSource;
const Template = require("../Template");
class WebWorkerHotUpdateChunkTemplatePlugin {
apply(hotUpdateChunkTemplate) {
hotUpdateChunkTemplate.hooks.render.tap("WebWorkerHotUpdateChunkTemplatePlugin", (modulesSource, modules, removedModules, hash, id) => {
const chunkCallbackName = hotUpdateChunkTemplate.outputOptions.hotUpdateFunction || Template.toIdentifier("webpackHotUpdate" + (hotUpdateChunkTemplate.outputOptions.library || ""));
const source = new ConcatSource();
source.add(chunkCallbackName + "(" + JSON.stringify(id) + ",");
source.add(modulesSource);
source.add(")");
return source;
});
hotUpdateChunkTemplate.hooks.hash.tap("WebWorkerHotUpdateChunkTemplatePlugin", hash => {
hash.update("WebWorkerHotUpdateChunkTemplatePlugin");
hash.update("3");
hash.update(hotUpdateChunkTemplate.outputOptions.hotUpdateFunction + "");
hash.update(hotUpdateChunkTemplate.outputOptions.library + "");
});
}
}
module.exports = WebWorkerHotUpdateChunkTemplatePlugin;