Webpack 5 HMR plugin error in runtime.[hash].hot-update.js
See original GitHub issueBug report
What is the current behavior? i am not sure whether this is webpack-dev-server issue or webpack or something else, however after 1st hot reload happens there is a constant error:
jsonp chunk loading:103 Uncaught TypeError: Cannot read property 'push' of undefined
at self.webpackHotUpdatePACKAGEJSONNAME (jsonp chunk loading:103)
self["webpackHotUpdatePACKAGEJSONNAME"] = (chunkId, moreModules, runtime) => {
for(var moduleId in moreModules) {
if(__webpack_require__.o(moreModules, moduleId)) {
currentUpdate[moduleId] = moreModules[moduleId];
if(currentUpdatedModulesList) currentUpdatedModulesList.push(moduleId);
}
}
if(runtime) currentUpdateRuntime.push(runtime); // error happens here
if(waitingUpdateResolves[chunkId]) {
waitingUpdateResolves[chunkId]();
waitingUpdateResolves[chunkId] = undefined;
}
};
If the current behavior is a bug, please provide the steps to reproduce.
launch dev-server with hot:true
What is the expected behavior?
does not happen in webpack@4
i think that the issue is that this variable currentUpdateRuntime
is accessed before it is initialized in:
__webpack_require__.hmrI.jsonp
or
__webpack_require__.hmrC.jsonp
Other relevant information: webpack version: 5.1.0 Node.js version: v12.18.0 Operating System: Windows 10 Additional tools: webpack-devs-server@latest
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Webpack's Hot Module Replacement Feature Explained
The manifest contains a compilation hash and a list of all modules. Webpack will inject the HMR runtime into the generated bundle.js file ......
Read more >Webpack-dev-server HMR not working with multiple entry ...
It seems like HMR has stopped working in my browser. Webpack is running and bundling it correctly! Any ideas? Thanks so far and...
Read more >Webpack & The Hot Module Replacement | by rajaraodv
1. File Changed. Webpack along with HMR plugin generates a manifest file “<previousHash>.hot-update.json” and the update file “< ...
Read more >Hot Module Replacement
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an ... Instantly update the browser when modifications are made to CSS/JS in...
Read more >Hot Module Replacement
Starting from webpack 5, there's an alternative to module.hot . import.meta. ... the HMR interface notified the client portion of the code of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@evilebottnawi I figured it out. It happens if any
XXX.hot-update.js
is by mistake loaded into the frontend as a standalone script. Thus not a Webpack bug, but detecting it automatically and throwing a clear error message may be a nice feature. The mistake is easy to do, if somebody takes chunk names from webpack stats and injects them all as<script>
into html (oiginally there is noxxx.hot-upload.js
chunks, and when they appear it is difficult to find out the problem from an obscure error message about a crush inside Webpack).I had the same issue when using Module Federation. If I remove the federated import (
import('MyModule/Button')
), then everything works fine. Adding the federated import and things break.I am using a proxy to avoid CORS issues, so that
localhost:3000
goes to myhost
app, andlocalhost:3000/federation/MyModule
redirects to myother
app.When the websocket message arrives, it inits
currentUpdateRuntime = []
.I think the issue is that the
webpack/runtime/jsonp chunk loading
(self.webpackHotUpdate
) is being loaded a second time when I import myother
app. In the dev tools, I can see that it’s being run from theother
app when it errors. So I suspect it’s re-initingvar currentUpdateRuntime;
.I guess its an issue with my entry point from my
other
app.