|
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | 4 | */ |
5 | | -var ConcatSource = require("webpack-sources").ConcatSource; |
| 5 | +"use strict"; |
6 | 6 |
|
7 | | -function JsonpHotUpdateChunkTemplatePlugin() {} |
8 | | -module.exports = JsonpHotUpdateChunkTemplatePlugin; |
| 7 | +const ConcatSource = require("webpack-sources").ConcatSource; |
| 8 | + |
| 9 | +class JsonpHotUpdateChunkTemplatePlugin { |
| 10 | + apply(hotUpdateChunkTemplate) { |
| 11 | + hotUpdateChunkTemplate.plugin("render", function(modulesSource, modules, removedModules, hash, id) { |
| 12 | + const source = new ConcatSource(); |
| 13 | + source.add(`${this.outputOptions.hotUpdateFunction}(${JSON.stringify(id)},`); |
| 14 | + source.add(modulesSource); |
| 15 | + source.add(")"); |
| 16 | + return source; |
| 17 | + }); |
| 18 | + hotUpdateChunkTemplate.plugin("hash", function(hash) { |
| 19 | + hash.update("JsonpHotUpdateChunkTemplatePlugin"); |
| 20 | + hash.update("3"); |
| 21 | + hash.update(`${this.outputOptions.hotUpdateFunction}`); |
| 22 | + hash.update(`${this.outputOptions.library}`); |
| 23 | + }); |
| 24 | + } |
| 25 | +} |
9 | 26 |
|
10 | | -JsonpHotUpdateChunkTemplatePlugin.prototype.apply = function(hotUpdateChunkTemplate) { |
11 | | - hotUpdateChunkTemplate.plugin("render", function(modulesSource, modules, removedModules, hash, id) { |
12 | | - var jsonpFunction = this.outputOptions.hotUpdateFunction; |
13 | | - var source = new ConcatSource(); |
14 | | - source.add(jsonpFunction + "(" + JSON.stringify(id) + ","); |
15 | | - source.add(modulesSource); |
16 | | - source.add(")"); |
17 | | - return source; |
18 | | - }); |
19 | | - hotUpdateChunkTemplate.plugin("hash", function(hash) { |
20 | | - hash.update("JsonpHotUpdateChunkTemplatePlugin"); |
21 | | - hash.update("3"); |
22 | | - hash.update(this.outputOptions.hotUpdateFunction + ""); |
23 | | - hash.update(this.outputOptions.library + ""); |
24 | | - }); |
25 | | -}; |
| 27 | +module.exports = JsonpHotUpdateChunkTemplatePlugin; |
0 commit comments