Skip to content

Commit 21d9b62

Browse files
committed
refactor(ES6): WebWorkerChunkPluginTemplate migration
linting
1 parent 8b0b7aa commit 21d9b62

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

lib/webworker/WebWorkerChunkTemplatePlugin.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
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)},${modules})`);
17+
return source;
18+
});
19+
chunkTemplate.plugin("hash", function(hash) {
20+
hash.update("webworker");
21+
hash.update("3");
22+
hash.update(this.outputOptions.chunkCallbackName + "");
23+
hash.update(this.outputOptions.library + "");
24+
});
25+
}
26+
}
27+
module.exports = WebWorkerChunkTemplatePlugin;

0 commit comments

Comments
 (0)