Socket
Socket
Sign inDemoInstall

webpack-hot-server-middleware

Package Overview
Dependencies
428
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.2 to 0.4.0

test/fixtures/singleservercompiler/server.js

32

index.d.ts

@@ -1,21 +0,19 @@

declare module 'webpack-hot-server-middleware' {
import { RequestHandler } from 'express';
// tslint:disable-next-line no-implicit-dependencies
import { MultiCompiler, Stats } from 'webpack';
type Options<T = Record<string, any>> = Partial<{
/** The name of the server entry point, defaults to 'main'. */
chunkName: string;
import { RequestHandler } from 'express';
// tslint:disable-next-line no-implicit-dependencies
import { MultiCompiler, Stats } from 'webpack';
type Options<T = Record<string, any>> = Partial<{
/** The name of the server entry point, defaults to 'main'. */
chunkName: string;
/** object Mixed in with clientStats & serverStats and passed to the serverRenderer. */
serverRendererOptions: T;
/** object Mixed in with clientStats & serverStats and passed to the serverRenderer. */
serverRendererOptions: T;
createHandler(error: boolean, serverRenderer: RequestHandler): RequestHandler;
}>;
createHandler(error: boolean, serverRenderer: RequestHandler): RequestHandler;
}>;
declare function webpackHotServerMiddleware<T>(
compiler: MultiCompiler,
options?: Options<T>,
): RequestHandler;
declare function webpackHotServerMiddleware<T>(
compiler: MultiCompiler,
options?: Options<T>,
): RequestHandler;
export = webpackHotServerMiddleware;
}
export = webpackHotServerMiddleware;
{
"name": "webpack-hot-server-middleware",
"version": "0.3.2",
"version": "0.4.0",
"description": "Hot updates Webpack bundles on the server",

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

@@ -110,3 +110,3 @@ 'use strict';

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

@@ -121,3 +121,3 @@

if (!clientCompilers.length) {
throw new Error(`Expected at least one webpack compiler prefixed with 'client'`);
debug(`Cannot find webpack compiler named 'client'. Starting without client compiler`);
}

@@ -135,3 +135,4 @@

error = false;
const clientStats = findStats(multiStats, 'client');
const serverStats = findStats(multiStats, 'server')[0];

@@ -144,6 +145,11 @@ // Server compilation errors need to be propagated to the client.

let clientStatsJson = clientStats.map(obj => obj.toJson());
let clientStatsJson = null;
if (clientStatsJson.length === 1) {
clientStatsJson = clientStatsJson[0];
if (clientCompilers.length) {
const clientStats = findStats(multiStats, 'client');
clientStatsJson = clientStats.map(obj => obj.toJson());
if (clientStatsJson.length === 1) {
clientStatsJson = clientStatsJson[0];
}
}

@@ -150,0 +156,0 @@

@@ -16,3 +16,3 @@ 'use strict';

const incorrectServerCompilerNameConfig = require('./fixtures/incorrectservercompilername/webpack.config.js');
const incorrectClientCompilerNameConfig = require('./fixtures/incorrectclientcompilername/webpack.config.js');
const singleServerCompilerConfig = require('./fixtures/singleservercompiler/webpack.config.js');
const badExportConfig = require('./fixtures/badexport/webpack.config.js');

@@ -59,3 +59,3 @@ const multipleClientsConfig = require('./fixtures/multipleclients/webpack.config.js');

expect(createServer.bind(null, noMultiCompilerConfig, false)).toThrow(
new Error(`Expected webpack compiler to contain both a 'client' and 'server' config`)
new Error(`Expected webpack compiler to contain both a 'client' and/or 'server' config`)
);

@@ -70,8 +70,2 @@ });

it('throws when client compiler cannot be found', () => {
expect(createServer.bind(null, incorrectClientCompilerNameConfig, false)).toThrow(
new Error(`Expected at least one webpack compiler prefixed with 'client'`)
);
});
it('handles commonJs exports', done => {

@@ -132,2 +126,19 @@ const [app, close] = createServer(commonJsConfig);

it('handles single server compiler', done => {
const [app, close] = createServer(singleServerCompilerConfig);
request(app)
.get('/')
.expect(200)
.expect('Hello Server')
.end((err, res) => {
close(() => {
if (err) {
done.fail(err);
return;
}
done();
});
});
});
it('handles source maps', done => {

@@ -134,0 +145,0 @@ const [app, close] = createServer(sourceMapConfig);

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