[fix] error on HMR with es6 bundles

Fix 5776
This commit is contained in:
Antoine Caron 2017-10-20 16:10:31 +02:00
parent 0c4d69b7c6
commit 27e4d14a31
3 changed files with 6 additions and 6 deletions

View File

@ -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");

View File

@ -82,8 +82,8 @@ class WebWorkerMainTemplatePlugin {
});
return source + "\n" +
`var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}];\n` +
`this[${JSON.stringify(hotUpdateFunction)}] = ` +
`var parentHotUpdateCallback = window[${JSON.stringify(hotUpdateFunction)}];\n` +
`window[${JSON.stringify(hotUpdateFunction)}] = ` +
Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js"))
.replace(/\/\/\$semicolon/g, ";")
.replace(/\$require\$/g, this.requireFn)

View File

@ -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 = window["webpackHotUpdate"];
window["webpackHotUpdate"] = function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
hotAddUpdateChunk(chunkId, moreModules);
if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
} ;