Webpack & The Hot Module Replacement

rajaraodv
rajaraodv
Apr 24, 2016 · 6 min read

Things To Note About HMR

How It Works

//Example: 0.b2e2d54372f42c1b2352.hot-update.js chunk
//Notice that the chunk is actually a function call to "webpackHotUpdate" HMR function. So when the chunk is loaded to the DOM, this function instantly called with the Chunk's info.
//In this case, style-loader is telling HMR about a new CSS class:
//input { background: pink;} for module id "82"

webpackHotUpdate(0,
{
82:
function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(79)();
exports.push([module.id, “input {\n background: pink;\n}”, “”])
}
})

A Deeper Look

0. Initial setup

1. File Changed

2. Update Client about the changes on the server

3. Upload changes

websocket, manifest and update files
manifest w/ details about the changes

4. Apply Changes

final logs after changes are made

My Other Posts

Functional Programming

ES6

WebPack

Draft.js

React And Redux :

Salesforce

rajaraodv

Written by

rajaraodv

Trying to make Web development simple. Former Developer Advocate @Salesforce, VMware (node.js); Engineer @ Yahoo, Zimbra. Twitter: @rajaraodv

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade