|
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | 4 | */ |
| 5 | +"use strict"; |
| 6 | + |
5 | 7 | var ConcatSource = require("webpack-sources").ConcatSource; |
6 | 8 | var Template = require("../Template"); |
7 | 9 |
|
8 | | -function WebWorkerChunkTemplatePlugin() {} |
9 | | -module.exports = WebWorkerChunkTemplatePlugin; |
| 10 | +class WebWorkerChunkTemplatePlugin { |
10 | 11 |
|
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