Socket
Socket
Sign inDemoInstall

webpack-hot-middleware

Package Overview
Dependencies
381
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.9.1 to 2.10.0

14

client-overlay.js

@@ -5,3 +5,2 @@ /*eslint-env browser*/

var styles = {
display: 'none',
background: 'rgba(0,0,0,0.85)',

@@ -26,6 +25,2 @@ color: '#E8E8E8',

if (document.body) {
document.body.appendChild(clientOverlay);
}
var ansiHTML = require('ansi-html');

@@ -52,3 +47,2 @@ var colors = {

clientOverlay.innerHTML = '';
clientOverlay.style.display = 'block';
lines.forEach(function(msg) {

@@ -61,2 +55,5 @@ msg = ansiHTML(entities.encode(msg));

});
if (document.body) {
document.body.appendChild(clientOverlay);
}
};

@@ -66,4 +63,5 @@

function clear() {
clientOverlay.innerHTML = '';
clientOverlay.style.display = 'none';
if (document.body && clientOverlay.parentNode) {
document.body.removeChild(clientOverlay);
}
};

@@ -70,0 +68,0 @@

@@ -81,21 +81,37 @@ /*eslint-env browser*/

var strip = require('strip-ansi');
var overlay;
if (typeof document !== 'undefined' && options.overlay) {
overlay = require('./client-overlay');
var reporter;
// the reporter needs to be a singleton on the page
// in case the client is being used by mutliple bundles
// we only want to report once.
// all the errors will go to all clients
var singletonKey = '__webpack_hot_middleware_reporter__';
if (typeof window !== 'undefined' && !window[singletonKey]) {
reporter = window[singletonKey] = createReporter();
}
function problems(type, obj) {
if (options.warn) {
console.warn("[HMR] bundle has " + type + ":");
obj[type].forEach(function(msg) {
console.warn("[HMR] " + strip(msg));
});
function createReporter() {
var strip = require('strip-ansi');
var overlay;
if (typeof document !== 'undefined' && options.overlay) {
overlay = require('./client-overlay');
}
if (overlay && type !== 'warnings') overlay.showProblems(type, obj[type]);
}
function success() {
if (overlay) overlay.clear();
return {
problems: function(type, obj) {
if (options.warn) {
console.warn("[HMR] bundle has " + type + ":");
obj[type].forEach(function(msg) {
console.warn("[HMR] " + strip(msg));
});
}
if (overlay && type !== 'warnings') overlay.showProblems(type, obj[type]);
},
success: function() {
if (overlay) overlay.clear();
},
useCustomOverlay: function(customOverlay) {
overlay = customOverlay;
}
};
}

@@ -110,8 +126,15 @@

} else if (obj.action == "built") {
if (options.log) console.log("[HMR] bundle " + (obj.name ? obj.name + " " : "") + "rebuilt in " + obj.time + "ms");
if (options.log) {
console.log(
"[HMR] bundle " + (obj.name ? obj.name + " " : "") +
"rebuilt in " + obj.time + "ms"
);
}
if (obj.errors.length > 0) {
problems('errors', obj);
if (reporter) reporter.problems('errors', obj);
} else {
if (obj.warnings.length > 0) problems('warnings', obj);
success();
if (reporter) {
if (obj.warnings.length > 0) reporter.problems('warnings', obj);
reporter.success();
}

@@ -131,5 +154,5 @@ processUpdate(obj.hash, obj.modules, options);

useCustomOverlay: function useCustomOverlay(customOverlay) {
overlay = customOverlay;
if (reporter) reporter.useCustomOverlay(customOverlay);
}
};
}
{
"name": "webpack-hot-middleware",
"version": "2.9.1",
"version": "2.10.0",
"description": "Webpack hot reloading you can attach to your own server",

@@ -5,0 +5,0 @@ "main": "middleware.js",

@@ -32,3 +32,3 @@ /**

function check() {
module.hot.check(function(err, updatedModules) {
var cb = function(err, updatedModules) {
if (err) return handleError(err);

@@ -45,3 +45,3 @@

module.hot.apply(applyOptions, function(applyErr, renewedModules) {
var applyCallback = function(applyErr, renewedModules) {
if (applyErr) return handleError(applyErr);

@@ -52,4 +52,24 @@

logUpdates(updatedModules, renewedModules);
});
});
};
var applyResult = module.hot.apply(applyOptions, applyCallback);
// webpack 2 promise
if (applyResult && applyResult.then) {
// HotModuleReplacement.runtime.js refers to the result as `outdatedModules`
applyResult.then(function(outdatedModules) {
applyCallback(null, outdatedModules);
});
applyResult.catch(applyCallback);
}
};
var result = module.hot.check(false, cb);
// webpack 2 promise
if (result && result.then) {
result.then(function(updatedModules) {
cb(null, updatedModules);
});
result.catch(cb);
}
}

@@ -56,0 +76,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc