webpack-hot-server-middleware
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -19,6 +19,6 @@ { | ||
"react-dom": "^16.0.0", | ||
"webpack": "^3.7.1", | ||
"webpack-dev-middleware": "^1.12.0", | ||
"webpack": "^4.1.1", | ||
"webpack-dev-middleware": "^3.0.1", | ||
"webpack-hot-server-middleware": "file:../" | ||
} | ||
} | ||
} |
@@ -8,2 +8,3 @@ const path = require('path'); | ||
name: 'client', | ||
mode: 'development', | ||
target: 'web', | ||
@@ -18,2 +19,3 @@ entry: './client', | ||
name: 'server', | ||
mode: 'development', | ||
target: 'node', | ||
@@ -20,0 +22,0 @@ entry: './express/server', |
{ | ||
"name": "webpack-hot-server-middleware", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Hot updates Webpack bundles on the server", | ||
@@ -24,5 +24,6 @@ "main": "src/", | ||
"dependencies": { | ||
"debug": "^2.2.0", | ||
"debug": "^3.1.0", | ||
"require-from-string": "^2.0.1", | ||
"source-map-support": "^0.4.2" | ||
"source-map-support": "^0.5.3", | ||
"yarn": "^1.5.1" | ||
}, | ||
@@ -33,13 +34,15 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"babel-jest": "^15.0.0", | ||
"babel-loader": "^6.2.5", | ||
"babel-plugin-istanbul": "^2.0.3", | ||
"babel-preset-es2015": "^6.16.0", | ||
"coveralls": "^2.11.14", | ||
"express": "^4.14.0", | ||
"jest": "^15.1.1", | ||
"supertest": "^2.0.0", | ||
"webpack": "^1.13.2", | ||
"webpack-dev-middleware": "^1.8.3" | ||
"babel-jest": "^22.4.1", | ||
"babel-loader": "^7.1.3", | ||
"babel-plugin-istanbul": "^4.1.5", | ||
"babel-preset-es2015": "^6.24.1", | ||
"coveralls": "^3.0.0", | ||
"express": "^4.16.2", | ||
"jest": "^22.4.2", | ||
"supertest": "^3.0.0", | ||
"webpack": "^4.1.1", | ||
"webpack-dev-middleware": "^3.0.1", | ||
"webpack-dev-middleware-legacy": "npm:webpack-dev-middleware@^2.0.2", | ||
"webpack-legacy": "npm:webpack@^3.0.0" | ||
} | ||
} | ||
} |
@@ -131,5 +131,4 @@ 'use strict'; | ||
multiCompiler.plugin('done', multiStats => { | ||
const doneHandler = (multiStats) => { | ||
error = false; | ||
@@ -166,4 +165,12 @@ const serverStats = findStats(multiStats, 'server')[0]; | ||
} | ||
}); | ||
}; | ||
if (multiCompiler.hooks) { | ||
// Webpack 4 | ||
multiCompiler.hooks.done.tap('WebpackHotServerMiddleware', doneHandler); | ||
} else { | ||
// Webpack 3 | ||
multiCompiler.plugin('done', doneHandler); | ||
} | ||
return function () { | ||
@@ -170,0 +177,0 @@ return options.createHandler(error, serverRenderer).apply(null, arguments); |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -19,2 +20,3 @@ entry: './client', | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -21,0 +23,0 @@ entry: './server', |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -19,2 +20,3 @@ entry: './client', | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -21,0 +23,0 @@ entry: './server', |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -19,2 +20,3 @@ entry: './client', | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -21,0 +23,0 @@ entry: './server', |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -19,2 +20,3 @@ entry: './client', | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -28,8 +30,10 @@ entry: './server', | ||
module: { | ||
loaders: [{ | ||
rules: [{ | ||
test: /\.js$/, | ||
exclude: 'node_modules', | ||
loader: 'babel-loader', | ||
query: { | ||
presets: ['es2015'] | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
query: { | ||
presets: ['babel-preset-es2015'] | ||
} | ||
} | ||
@@ -36,0 +40,0 @@ }] |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -19,2 +20,3 @@ entry: './client', | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -21,0 +23,0 @@ entry: './server', |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -19,2 +20,3 @@ entry: './mobile', | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -29,2 +31,3 @@ entry: './desktop', | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -31,0 +34,0 @@ entry: './server', |
@@ -8,2 +8,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -10,0 +11,0 @@ entry: './client', |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -19,2 +20,3 @@ entry: './client', | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -21,0 +23,0 @@ entry: './server', |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -11,0 +12,0 @@ entry: './server', |
@@ -9,2 +9,3 @@ const path = require('path'); | ||
target: 'web', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -20,2 +21,3 @@ entry: './client', | ||
target: 'node', | ||
mode: 'development', | ||
context: __dirname, | ||
@@ -22,0 +24,0 @@ entry: './server', |
@@ -5,4 +5,6 @@ 'use strict'; | ||
const webpack = require('webpack'); | ||
const webpackLegacy = require('webpack-legacy'); | ||
const request = require('supertest'); | ||
const webpackDevMiddleware = require('webpack-dev-middleware'); | ||
const webpackDevMiddlewareLegacy = require('webpack-dev-middleware-legacy'); | ||
const webpackHotServerMiddleware = require('../src'); | ||
@@ -20,2 +22,3 @@ | ||
const multipleClientsConfig = require('./fixtures/multipleclients/webpack.config.js'); | ||
const legacyConfig = require('./fixtures/legacy/webpack.config.js'); | ||
@@ -27,5 +30,3 @@ function createServer(config, mountWebpackDevMiddleware = true) { | ||
if (mountWebpackDevMiddleware) { | ||
webpackDev = webpackDevMiddleware(compiler, { | ||
quiet: true | ||
}); | ||
webpackDev = webpackDevMiddleware(compiler, { logLevel: 'silent' }); | ||
app.use(webpackDev); | ||
@@ -55,4 +56,33 @@ } | ||
function createLegacyServer(config, mountWebpackDevMiddleware = true) { | ||
const compiler = webpackLegacy(config); | ||
const app = express(); | ||
let webpackDev; | ||
if (mountWebpackDevMiddleware) { | ||
webpackDev = webpackDevMiddlewareLegacy(compiler, { logLevel: 'silent' }); | ||
app.use(webpackDev); | ||
} | ||
app.use(webpackHotServerMiddleware(compiler)); | ||
app.use((err, req, res, next) => { | ||
res.status(500).send(err.toString()); | ||
}); | ||
return [app, (cb) => { | ||
// HACK: Process won't terminate unless `close` is successful however | ||
// 'chokidar' has a bug whereby calling `close` before the watcher is | ||
// ready fails so having to wait for...a bit. | ||
// https://github.com/webpack/webpack/issues/1920 | ||
// https://github.com/paulmillr/chokidar/pull/536 | ||
setTimeout(() => { | ||
if (webpackDev) { | ||
webpackDev.close(cb); | ||
return; | ||
} | ||
if (cb) { | ||
cb(); | ||
} | ||
}, 100); | ||
}]; | ||
} | ||
describe('index', () => { | ||
it('throws when the compiler isn\'t a `MultiCompiler`', () => { | ||
@@ -212,2 +242,18 @@ // Avoid mounting webpackDevMiddleware as we expect it to throw so would | ||
it(`handles legacy webpack`, done => { | ||
const [app, close] = createLegacyServer(legacyConfig); | ||
request(app) | ||
.get('/') | ||
.expect(200) | ||
.expect('Hello Server') | ||
.end((err, res) => { | ||
close(() => { | ||
if (err) { | ||
done.fail(err); | ||
return; | ||
} | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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
306298
54
848
5
12
+ Addedyarn@^1.5.1
+ Addeddebug@3.2.7(transitive)
+ Addedelectron-to-chromium@1.5.56(transitive)
+ Addedms@2.1.3(transitive)
+ Addedyarn@1.22.22(transitive)
- Removeddebug@2.6.9(transitive)
- Removedelectron-to-chromium@1.5.57(transitive)
- Removedms@2.0.0(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-support@0.4.18(transitive)
Updateddebug@^3.1.0
Updatedsource-map-support@^0.5.3