Skip to content

Commit 0607fc1

Browse files
willmendesnetoTheLarkInn
authored andcommitted
refactor(JsonpHotUpdateChunkTemplatePlugin): upgrade to ES6 (webpack#3831)
1 parent d803bc1 commit 0607fc1

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

‎lib/JsonpHotUpdateChunkTemplatePlugin.js‎

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
var ConcatSource = require("webpack-sources").ConcatSource;
5+
"use strict";
66

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+
}
926

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

Comments
 (0)