Skip to content

Commit

Permalink
Merge pull request #5862 from Slashgear/fix-hmr-es6-bundles
Browse files Browse the repository at this point in the history
[fix] error on HMR with es6 bundles
  • Loading branch information
sokra committed Nov 27, 2017
2 parents 9c1f9fe + 00daab2 commit 801a253
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/JsonpMainTemplatePlugin.js
Expand Up @@ -195,8 +195,8 @@ class JsonpMainTemplatePlugin {
function hotDisposeChunk(chunkId) {
delete installedChunks[chunkId];
}
var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}];
this[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
var parentHotUpdateCallback = window[${JSON.stringify(hotUpdateFunction)}];
window[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
});
mainTemplate.plugin("hash", function(hash) {
hash.update("jsonp");
Expand Down
4 changes: 2 additions & 2 deletions lib/webworker/WebWorkerMainTemplatePlugin.js
Expand Up @@ -82,8 +82,8 @@ class WebWorkerMainTemplatePlugin {
});

return source + "\n" +
`var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}];\n` +
`this[${JSON.stringify(hotUpdateFunction)}] = ` +
`var parentHotUpdateCallback = self[${JSON.stringify(hotUpdateFunction)}];\n` +
`self[${JSON.stringify(hotUpdateFunction)}] = ` +
Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js"))
.replace(/\/\/\$semicolon/g, ";")
.replace(/\$require\$/g, this.requireFn)
Expand Down
4 changes: 2 additions & 2 deletions test/WebWorkerMainTemplatePlugin.unittest.js
Expand Up @@ -188,8 +188,8 @@ installedChunks[chunkIds.pop()] = 1;
it("returns the original source with hot update callback", () => {
env.source.should.be.exactly(`
moduleSource()
var parentHotUpdateCallback = this["webpackHotUpdate"];
this["webpackHotUpdate"] = function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
var parentHotUpdateCallback = self["webpackHotUpdate"];
self["webpackHotUpdate"] = function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
hotAddUpdateChunk(chunkId, moreModules);
if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
} ;
Expand Down

0 comments on commit 801a253

Please sign in to comment.