From 5aa522d5be9a207bfce7f2c97eed2d8ec6b77698 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Sun, 8 Jan 2017 09:37:59 +0530 Subject: [PATCH] refactor(ES6): upgrade NodeHotUpdateChunkTemplatePlugin to ES6 (#3795) --- lib/node/NodeHotUpdateChunkTemplatePlugin.js | 39 +++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/node/NodeHotUpdateChunkTemplatePlugin.js b/lib/node/NodeHotUpdateChunkTemplatePlugin.js index 124b21e33..aad593d38 100644 --- a/lib/node/NodeHotUpdateChunkTemplatePlugin.js +++ b/lib/node/NodeHotUpdateChunkTemplatePlugin.js @@ -2,23 +2,26 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -var ConcatSource = require("webpack-sources").ConcatSource; +"use strict"; -function NodeHotUpdateChunkTemplatePlugin() {} +const ConcatSource = require("webpack-sources").ConcatSource; + +class NodeHotUpdateChunkTemplatePlugin { + + apply(hotUpdateChunkTemplate) { + hotUpdateChunkTemplate.plugin("render", (modulesSource, modules, removedModules, hash, id) => { + const source = new ConcatSource(); + source.add("exports.id = " + JSON.stringify(id) + ";\nexports.modules = "); + source.add(modulesSource); + source.add(";"); + return source; + }); + hotUpdateChunkTemplate.plugin("hash", function(hash) { + hash.update("NodeHotUpdateChunkTemplatePlugin"); + hash.update("3"); + hash.update(this.outputOptions.hotUpdateFunction + ""); + hash.update(this.outputOptions.library + ""); + }); + } +} module.exports = NodeHotUpdateChunkTemplatePlugin; - -NodeHotUpdateChunkTemplatePlugin.prototype.apply = function(hotUpdateChunkTemplate) { - hotUpdateChunkTemplate.plugin("render", function(modulesSource, modules, removedModules, hash, id) { - var source = new ConcatSource(); - source.add("exports.id = " + JSON.stringify(id) + ";\nexports.modules = "); - source.add(modulesSource); - source.add(";"); - return source; - }); - hotUpdateChunkTemplate.plugin("hash", function(hash) { - hash.update("NodeHotUpdateChunkTemplatePlugin"); - hash.update("3"); - hash.update(this.outputOptions.hotUpdateFunction + ""); - hash.update(this.outputOptions.library + ""); - }); -};