Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack-hot-server-middleware

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-hot-server-middleware - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.babelrc

19

package.json
{
"name": "webpack-hot-server-middleware",
"version": "0.0.3",
"version": "0.0.4",
"description": "Hot updates Webpack bundles on the server",

@@ -9,2 +9,7 @@ "main": "src/",

},
"jest": {
"testEnvironment": "node",
"setupTestFrameworkScriptFile": "<rootDir>/test/support/setup.js",
"preprocessorIgnorePatterns": ["/node_modules/", "<rootDir>/src"]
},
"repository": {

@@ -21,3 +26,3 @@ "type": "git",

"debug": "^2.2.0",
"require-from-string": "^1.2.0",
"require-from-string": "^1.2.1",
"source-map-support": "^0.4.2"

@@ -27,3 +32,13 @@ },

"webpack": "*"
},
"devDependencies": {
"babel-jest": "^15.0.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.16.0",
"express": "^4.14.0",
"jest": "^15.1.1",
"supertest": "^2.0.0",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.8.3"
}
}

4

README.md

@@ -1,2 +0,2 @@

# Webpack Hot Server Middleware
# Webpack Hot Server Middleware [![Build Status](https://travis-ci.org/60frames/webpack-hot-server-middleware.svg?branch=master)](https://travis-ci.org/60frames/webpack-hot-server-middleware) [![npm version](https://badge.fury.io/js/webpack-hot-server-middleware.svg)](https://badge.fury.io/js/wwebpack-hot-server-middleware)

@@ -115,3 +115,3 @@ ## What?

An example setup can be found in the [example](example) directory.
A simple example can be found in the [example](example) directory and a more real world example can be seen in the [60fram.es boilerplate](https://github.com/60frames/react-boilerplate)

@@ -118,0 +118,0 @@ ## License

@@ -25,4 +25,4 @@ 'use strict';

function getChunkFilename(stats, outputPath, chunkName) {
const assetsByChunkName = stats.toJson().assetsByChunkName;
function getFilename(serverStats, outputPath, chunkName) {
const assetsByChunkName = serverStats.toJson().assetsByChunkName;
let filename = assetsByChunkName[chunkName] || '';

@@ -38,2 +38,20 @@ // If source maps are generated `assetsByChunkName.main`

function getServerRenderer(filename, buffer, clientStats) {
const errMessage = `The 'server' compiler must export a function in the form of \`(stats) => (req, res, next) => void 0\``;
let serverRenderer = interopRequireDefault(
requireFromString(buffer.toString(), filename)
);
if (typeof serverRenderer !== 'function') {
throw new Error(errMessage);
}
serverRenderer = serverRenderer(clientStats.toJson());
if (typeof serverRenderer !== 'function') {
throw new Error(errMessage);
}
return serverRenderer;
}
function installSourceMapSupport(fs) {

@@ -51,3 +69,3 @@ sourceMapSupport.install({

};
} catch(e) {
} catch(ex) {
// Doesn't exist

@@ -72,4 +90,4 @@ }

if (!multiCompiler instanceof MultiCompiler) {
throw new Error('Expected webpack compiler to contain both a `client` and `server` config');
if (!(multiCompiler instanceof MultiCompiler)) {
throw new Error(`Expected webpack compiler to contain both a 'client' and 'server' config`);
}

@@ -81,6 +99,6 @@

if (!serverCompiler) {
throw new Error('Expected a webpack compiler named `server`');
throw new Error(`Expected a webpack compiler named 'server'`);
}
if (!clientCompiler) {
throw new Error('Expected a webpack compiler named `client`');
throw new Error(`Expected a webpack compiler named 'client'`);
}

@@ -97,2 +115,3 @@

multiCompiler.plugin('done', multiStats => {
error = false;
const clientStats = findStats(multiStats, 'client');

@@ -105,12 +124,9 @@ const serverStats = findStats(multiStats, 'server');

}
error = false;
const filename = getChunkFilename(serverStats, outputPath, options.chunkName);
const filename = getFilename(serverStats, outputPath, options.chunkName);
const buffer = outputFs.readFileSync(filename);
try {
const data = outputFs.readFileSync(filename);
serverRenderer = interopRequireDefault(
requireFromString(data.toString(), filename)
)(clientStats.toJson());
} catch (e) {
debug(e);
error = e;
serverRenderer = getServerRenderer(filename, buffer, clientStats);
} catch (ex) {
debug(ex);
error = ex;
}

@@ -117,0 +133,0 @@ });

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc