New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional follow-up fix for #1704 to remove remaining warnings #1736
Changes from 7 commits
2a362ae
de1903e
2cd8075
e03de48
722186a
a859278
9754732
8c90455
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
const devserverPkg = require('webpack-dev-server/package.json'); | ||
|
||
module.exports = devserverPkg.version ? parseInt(devserverPkg.version[0]) : 3; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ const logger = require('razzle-dev-utils/logger'); | |
const setPorts = require('razzle-dev-utils/setPorts'); | ||
const chalk = require('chalk'); | ||
const terminate = require('terminate'); | ||
const devServerMajorVersion = require('razzle-dev-utils/devServerMajor'); | ||
|
||
let verbose = false; | ||
|
||
|
@@ -172,20 +173,30 @@ function main() { | |
// This will actually run on a different port than the users app. | ||
clientDevServer = new devServer( | ||
clientCompiler, | ||
Object.assign(clientConfig.devServer, { verbose: verbose }) | ||
Object.assign(clientConfig.devServer, { verbose, port }), | ||
); | ||
// Start Webpack-dev-server | ||
clientDevServer.listen(port, err => { | ||
if (err) { | ||
logger.error(err); | ||
} | ||
}); | ||
if (devServerMajorVersion > 3) { | ||
// listen was deprecated in v4 and causes issues when used, switch to its replacement | ||
clientDevServer.start(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use startCallback if you want to have feature parity on the error handler. const startCallback = (error) => err && logger.error(err);
clientDevServer.startCallback(startCallback , startCallback); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can add the same (not parity) to stop with stopCallback, which I believe will only trigger if a middleware is unable to close. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the source code for startCallback and stopCallback currently, (err) will always be null... But I can add it in case things change in the future. Or maybe I'll just add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good callout. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok... Pushed code to support this, assuming that the new issue I filed on |
||
} else { | ||
// Start Webpack-dev-server | ||
clientDevServer.listen(port, err => { | ||
if (err) { | ||
logger.error(err); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
['SIGINT', 'SIGTERM'].forEach(sig => { | ||
process.on(sig, () => { | ||
if (clientDevServer) { | ||
clientDevServer.close(); | ||
if (devServerMajorVersion > 3) { | ||
// close was deprecated in v4, switch to its replacement | ||
clientDevServer.stop(); | ||
} else { | ||
clientDevServer.close(); | ||
} | ||
} | ||
if (watching) { | ||
watching.close(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍