Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ wps-hmr.*
coverage.lcov

dist

*.pem
*.key
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ If `true`, will enable [`Hot Module Replacement`](https://webpack.js.org/concept

_Note: If the build process generates errors, the client (browser) will not be notified of new changes and no HMR will be performed. Errors must be resolved before HMR can proceed. To force a refresh, pass `refresh-on-failure' to this option._

_Note: If using in combination with `http2`, the `http2` option `allowHTTP1` must be enabled for the HMR WS connection to work._
_Note: If using in combination with `http2`, the `http2` option `allowHTTP1` will be enabled by default for the HMR WS connection to work._

### `host`
Type: `String | Promise`<br>
Expand All @@ -151,9 +151,9 @@ _Note: The default URI is `http://[::]:{port}`. For more info, please read [the
### `http2`
Type: `boolean` | [`http2` options](https://nodejs.org/api/http2.html#http2_http2_createserver_options_onrequesthandler) | [secure `http2` options](https://nodejs.org/api/http2.html#http2_http2_createsecureserver_options_onrequesthandler)

If set, this option will instruct the server to enable HTTP2. Properties for this option should correspond to [HTTP2 options][http2] or [HTTP2 SSL options][http2tls].
If set, this option will instruct the server to enable HTTP2. Properties for this option should correspond to [HTTP2 options][http2] or [HTTP2 SSL options][http2tls]. Browsers currently do not support unencrypted HTTP2 connections, so you will need to enable SSL for this to work properly.

_Note: If using in combination with `hmr`, the option `allowHTTP1` must be enabled for the HMR WS connection to work._
_Note: If using in combination with `hmr`, the option `allowHTTP1` will be enabled by default for the HMR WS connection to work._

### `https`
Type: `Object`<br>
Expand Down
9 changes: 5 additions & 4 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ const select = (options, callback) => {
http2: require('http2').createServer,
http2Secure: require('http2').createSecureServer
};
const { http2, https } = options;
const { http2, https, hmr } = options;
let server;
let secure = false;

if (http2) {
const defaultOptions = hmr === true ? { allowHTTP1: true } : {};
if (http2 === true) {
server = types.http2({}, callback);
server = types.http2(defaultOptions, callback);
} else if (http2.cert) {
secure = true;
server = types.http2Secure(http2, callback);
server = types.http2Secure({ ...defaultOptions, ...http2 }, callback);
} else {
server = types.http2(http2, callback);
server = types.http2({ ...defaultOptions, ...http2 }, callback);
}
} else if (https) {
secure = true;
Expand Down
Loading