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.2 to 0.0.3

example/client.js

2

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

@@ -5,0 +5,0 @@ "main": "src/",

@@ -19,3 +19,3 @@ # Webpack Hot Server Middleware

ReactDOM.render(<App />, document.getElementById('#root'));
ReactDOM.render(<App />, document.getElementById('root'));
```

@@ -31,3 +31,3 @@

export default function universalRenderer() {
export default function serverRenderer() {
return (req, res, next) => {

@@ -44,3 +44,3 @@ res.status(200).send(`

</div>
<script src="/bundle.js"></script>
<script src="/client.js"></script>
</body>

@@ -57,6 +57,6 @@ </html>

const express = require('express');
const universalRenderer = require('./dist/server');
const serverRenderer = require('./dist/server');
const app = express();
app.use(universalRenderer());
app.use(serverRenderer());
app.listen(6060);

@@ -86,4 +86,3 @@ ```

...
},
{
}, {
name: 'server',

@@ -113,4 +112,14 @@ target: 'node',

app.use(webpackHotServerMiddleware(compiler));
app.listen(6060);
```
Now whenever Webpack rebuilds the new bundle will be used both client and *server* side.
### Example
An example setup can be found in the [example](example) directory.
## License
MIT

@@ -13,2 +13,6 @@ 'use strict';

function interopRequireDefault(obj) {
return obj && obj.__esModule ? obj.default : obj;
}
function findCompiler(multiCompiler, name) {

@@ -85,3 +89,3 @@ return multiCompiler.compilers.find(compiler => compiler.name === name);

let universalRenderer;
let serverRenderer;
let error = false;

@@ -101,3 +105,5 @@

const data = outputFs.readFileSync(filename);
universalRenderer = requireFromString(data.toString(), filename).default(clientStats.toJson());
serverRenderer = interopRequireDefault(
requireFromString(data.toString(), filename)
)(clientStats.toJson());
} catch (e) {

@@ -114,3 +120,3 @@ debug(e);

}
universalRenderer(req, res, next);
serverRenderer(req, res, next);
};

@@ -117,0 +123,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