webpack-hot-middleware
Advanced tools
Comparing version 1.2.0 to 2.0.0
@@ -7,3 +7,4 @@ /*eslint-env browser*/ | ||
timeout: 20 * 1000, | ||
overlay: true | ||
overlay: true, | ||
reload: false | ||
}; | ||
@@ -23,2 +24,6 @@ if (__resourceQuery) { | ||
} | ||
var reloadMatch = /reload=(.*?)(\&|$)/.exec(__resourceQuery); | ||
if (reloadMatch) { | ||
options.reload = reloadMatch[1] !== 'false'; | ||
} | ||
} | ||
@@ -62,3 +67,3 @@ | ||
source.close(); | ||
setTimeout(connect, 500); | ||
setTimeout(connect, options.timeout); | ||
} | ||
@@ -89,2 +94,3 @@ | ||
var processUpdate = require('./processUpdate'); | ||
@@ -102,5 +108,5 @@ function processMessage(obj) { | ||
success(); | ||
window.postMessage("webpackHotUpdate" + obj.hash, "*"); | ||
processUpdate(obj.hash, obj.modules, options.reload); | ||
} | ||
} | ||
} |
@@ -6,5 +6,3 @@ var webpack = require('webpack'); | ||
entry: [ | ||
// Webpack comes with client code to check & reload modules | ||
'webpack/hot/dev-server', | ||
// We need to add our own code to receive module change notifications | ||
// Add the client which connects to our middleware | ||
'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000', | ||
@@ -24,3 +22,3 @@ // And then the actual application | ||
new webpack.NoErrorsPlugin() | ||
] | ||
], | ||
}; |
@@ -24,3 +24,4 @@ module.exports = webpackHotMiddleware; | ||
warnings: stats.warnings || [], | ||
errors: stats.errors || [] | ||
errors: stats.errors || [], | ||
modules: buildModuleMap(stats.modules) | ||
}); | ||
@@ -42,3 +43,3 @@ }); | ||
} | ||
setInterval(function heartbeat() { | ||
setInterval(function heartbeatTick() { | ||
everyClient(function(client) { | ||
@@ -71,1 +72,9 @@ client.write("data: \uD83D\uDC93\n\n"); | ||
} | ||
function buildModuleMap(modules) { | ||
var map = {}; | ||
modules.forEach(function(module) { | ||
map[module.id] = module.name; | ||
}); | ||
return map; | ||
} |
{ | ||
"name": "webpack-hot-middleware", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "Webpack hot reloading you can attach to your own server", | ||
@@ -5,0 +5,0 @@ "main": "middleware.js", |
@@ -28,8 +28,5 @@ # Webpack Hot Middleware | ||
2. Add `'webpack/hot/dev-server'` into the `entry` array. | ||
This allows webpack to detect and reload updated modules when notified. | ||
3. Add `'webpack-hot-middleware/client'` into the `entry` array. | ||
This connects to the server to receive notifications when the bundle | ||
rebuilds. | ||
rebuilds and then updates your client bundle accordingly. | ||
@@ -56,2 +53,12 @@ Now add the middleware into your server: | ||
## Changelog | ||
### 2.0.0 | ||
**Breaking Change** | ||
As of version 2.0.0, all client functionality has been rolled into this module. This means that you should remove any reference to `webpack/hot/dev-server` or `webpack/hot/only-dev-server` from your webpack config. Instead, use the `reload` config option to control this behaviour. | ||
This was done to allow full control over the client receiving updates, which is now able to output full module names in the console when applying changes. | ||
## Documentation | ||
@@ -72,2 +79,3 @@ | ||
* **overlay** - Set to `false` to disable the DOM-based client-side overlay. | ||
* **reload** - Set to `true` to auto-reload the page when webpack gets stuck. | ||
@@ -74,0 +82,0 @@ ## License |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15729
15
352
84