Skip to content

Commit 16b9f73

Browse files
authored
Merge pull request webpack#4316 from sendilkumarn/wwcpt-es6
refactor(ES6): WebWorkerChunkPluginTemplate migration
2 parents f8c3e63 + db2ff05 commit 16b9f73

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

lib/webworker/WebWorkerChunkTemplatePlugin.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5+
"use strict";
6+
57
var ConcatSource = require("webpack-sources").ConcatSource;
68
var Template = require("../Template");
79

8-
function WebWorkerChunkTemplatePlugin() {}
9-
module.exports = WebWorkerChunkTemplatePlugin;
10+
class WebWorkerChunkTemplatePlugin {
1011

11-
WebWorkerChunkTemplatePlugin.prototype.apply = function(chunkTemplate) {
12-
chunkTemplate.plugin("render", function(modules, chunk) {
13-
var chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
14-
var source = new ConcatSource();
15-
source.add(chunkCallbackName + "(" + JSON.stringify(chunk.ids) + ",");
16-
source.add(modules);
17-
source.add(")");
18-
return source;
19-
});
20-
chunkTemplate.plugin("hash", function(hash) {
21-
hash.update("webworker");
22-
hash.update("3");
23-
hash.update(this.outputOptions.chunkCallbackName + "");
24-
hash.update(this.outputOptions.library + "");
25-
});
26-
};
12+
apply(chunkTemplate) {
13+
chunkTemplate.plugin("render", function(modules, chunk) {
14+
const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
15+
const source = new ConcatSource();
16+
source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},`);
17+
source.add(modules);
18+
source.add(")");
19+
return source;
20+
});
21+
chunkTemplate.plugin("hash", function(hash) {
22+
hash.update("webworker");
23+
hash.update("3");
24+
hash.update(`${this.outputOptions.chunkCallbackName}`);
25+
hash.update(`${this.outputOptions.library}`);
26+
});
27+
}
28+
}
29+
module.exports = WebWorkerChunkTemplatePlugin;

0 commit comments

Comments
 (0)