From 21d9b62f339362167c1c1d8474f80c7175a67a35 Mon Sep 17 00:00:00 2001 From: SendilKumar N Date: Mon, 20 Feb 2017 21:28:20 +0800 Subject: [PATCH 1/2] refactor(ES6): WebWorkerChunkPluginTemplate migration linting --- lib/webworker/WebWorkerChunkTemplatePlugin.js | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/webworker/WebWorkerChunkTemplatePlugin.js b/lib/webworker/WebWorkerChunkTemplatePlugin.js index 59c3d4ad7..dac9bf26d 100644 --- a/lib/webworker/WebWorkerChunkTemplatePlugin.js +++ b/lib/webworker/WebWorkerChunkTemplatePlugin.js @@ -2,25 +2,26 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ +"use strict"; + var ConcatSource = require("webpack-sources").ConcatSource; var Template = require("../Template"); -function WebWorkerChunkTemplatePlugin() {} -module.exports = WebWorkerChunkTemplatePlugin; +class WebWorkerChunkTemplatePlugin { -WebWorkerChunkTemplatePlugin.prototype.apply = function(chunkTemplate) { - chunkTemplate.plugin("render", function(modules, chunk) { - var chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || "")); - var source = new ConcatSource(); - source.add(chunkCallbackName + "(" + JSON.stringify(chunk.ids) + ","); - source.add(modules); - source.add(")"); - return source; - }); - chunkTemplate.plugin("hash", function(hash) { - hash.update("webworker"); - hash.update("3"); - hash.update(this.outputOptions.chunkCallbackName + ""); - hash.update(this.outputOptions.library + ""); - }); -}; + apply(chunkTemplate) { + chunkTemplate.plugin("render", function(modules, chunk) { + const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || "")); + const source = new ConcatSource(); + source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},${modules})`); + return source; + }); + chunkTemplate.plugin("hash", function(hash) { + hash.update("webworker"); + hash.update("3"); + hash.update(this.outputOptions.chunkCallbackName + ""); + hash.update(this.outputOptions.library + ""); + }); + } +} +module.exports = WebWorkerChunkTemplatePlugin; From db2ff057f1c8b2fae2fe7bfe0d26d4abdb8405de Mon Sep 17 00:00:00 2001 From: SendilKumar N Date: Tue, 21 Feb 2017 06:14:02 +0800 Subject: [PATCH 2/2] changing as per comments --- lib/webworker/WebWorkerChunkTemplatePlugin.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/webworker/WebWorkerChunkTemplatePlugin.js b/lib/webworker/WebWorkerChunkTemplatePlugin.js index dac9bf26d..870252b7a 100644 --- a/lib/webworker/WebWorkerChunkTemplatePlugin.js +++ b/lib/webworker/WebWorkerChunkTemplatePlugin.js @@ -13,14 +13,16 @@ class WebWorkerChunkTemplatePlugin { chunkTemplate.plugin("render", function(modules, chunk) { const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || "")); const source = new ConcatSource(); - source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},${modules})`); + source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},`); + source.add(modules); + source.add(")"); return source; }); chunkTemplate.plugin("hash", function(hash) { hash.update("webworker"); hash.update("3"); - hash.update(this.outputOptions.chunkCallbackName + ""); - hash.update(this.outputOptions.library + ""); + hash.update(`${this.outputOptions.chunkCallbackName}`); + hash.update(`${this.outputOptions.library}`); }); } }