Skip to content

Commit 0168882

Browse files
committed
Change __webpack_require__.e to be assigned as a function property (e = fn() { ... }) instead of using Object.defineProperty. This allows it to be set/changed temporarily by tests, such as the test for issue-758.
1 parent f92f325 commit 0168882

1 file changed

Lines changed: 18 additions & 21 deletions

File tree

lib/HotModuleReplacement.runtime.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,31 @@ module.exports = function() {
4343
};
4444
};
4545
for(var name in $require$) {
46-
if(Object.prototype.hasOwnProperty.call($require$, name)) {
46+
if(Object.prototype.hasOwnProperty.call($require$, name) && name !== "e") {
4747
Object.defineProperty(fn, name, ObjectFactory(name));
4848
}
4949
}
50-
Object.defineProperty(fn, "e", {
51-
enumerable: true,
52-
value: function(chunkId) {
53-
if(hotStatus === "ready")
54-
hotSetStatus("prepare");
55-
hotChunksLoading++;
56-
return $require$.e(chunkId).then(finishChunkLoading, function(err) {
57-
finishChunkLoading();
58-
throw err;
59-
});
50+
fn.e = function(chunkId) {
51+
if(hotStatus === "ready")
52+
hotSetStatus("prepare");
53+
hotChunksLoading++;
54+
return $require$.e(chunkId).then(finishChunkLoading, function(err) {
55+
finishChunkLoading();
56+
throw err;
57+
});
6058

61-
function finishChunkLoading() {
62-
hotChunksLoading--;
63-
if(hotStatus === "prepare") {
64-
if(!hotWaitingFilesMap[chunkId]) {
65-
hotEnsureUpdateChunk(chunkId);
66-
}
67-
if(hotChunksLoading === 0 && hotWaitingFiles === 0) {
68-
hotUpdateDownloaded();
69-
}
59+
function finishChunkLoading() {
60+
hotChunksLoading--;
61+
if(hotStatus === "prepare") {
62+
if(!hotWaitingFilesMap[chunkId]) {
63+
hotEnsureUpdateChunk(chunkId);
64+
}
65+
if(hotChunksLoading === 0 && hotWaitingFiles === 0) {
66+
hotUpdateDownloaded();
7067
}
7168
}
7269
}
73-
});
70+
};
7471
return fn;
7572
}
7673

0 commit comments

Comments
 (0)