Skip to content

Commit 801a253

Browse files
authored
Merge pull request webpack#5862 from Slashgear/fix-hmr-es6-bundles
[fix] error on HMR with es6 bundles
2 parents 9c1f9fe + 00daab2 commit 801a253

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/JsonpMainTemplatePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ class JsonpMainTemplatePlugin {
195195
function hotDisposeChunk(chunkId) {
196196
delete installedChunks[chunkId];
197197
}
198-
var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}];
199-
this[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
198+
var parentHotUpdateCallback = window[${JSON.stringify(hotUpdateFunction)}];
199+
window[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
200200
});
201201
mainTemplate.plugin("hash", function(hash) {
202202
hash.update("jsonp");

lib/webworker/WebWorkerMainTemplatePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class WebWorkerMainTemplatePlugin {
8282
});
8383

8484
return source + "\n" +
85-
`var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}];\n` +
86-
`this[${JSON.stringify(hotUpdateFunction)}] = ` +
85+
`var parentHotUpdateCallback = self[${JSON.stringify(hotUpdateFunction)}];\n` +
86+
`self[${JSON.stringify(hotUpdateFunction)}] = ` +
8787
Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js"))
8888
.replace(/\/\/\$semicolon/g, ";")
8989
.replace(/\$require\$/g, this.requireFn)

test/WebWorkerMainTemplatePlugin.unittest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ installedChunks[chunkIds.pop()] = 1;
188188
it("returns the original source with hot update callback", () => {
189189
env.source.should.be.exactly(`
190190
moduleSource()
191-
var parentHotUpdateCallback = this["webpackHotUpdate"];
192-
this["webpackHotUpdate"] = function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
191+
var parentHotUpdateCallback = self["webpackHotUpdate"];
192+
self["webpackHotUpdate"] = function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
193193
hotAddUpdateChunk(chunkId, moreModules);
194194
if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
195195
} ;

0 commit comments

Comments
 (0)