webpack-hot-client
Advanced tools
Comparing version 4.0.4 to 4.1.0-beta.1
@@ -49,4 +49,4 @@ const { Server: HttpsServer } = require('https'); | ||
options.host = { | ||
client: options.host, | ||
server: options.host, | ||
client: options.host, | ||
}; | ||
@@ -63,9 +63,28 @@ } else if (!options.host.server) { | ||
if (typeof options.port === 'number') { | ||
options.port = { | ||
client: options.port, | ||
server: options.port, | ||
}; | ||
} else if (!options.port.server) { | ||
throw new HotClientError( | ||
'`port.server` must be defined when setting host to an Object' | ||
); | ||
} else if (!options.port.client) { | ||
throw new HotClientError( | ||
'`port.client` must be defined when setting host to an Object' | ||
); | ||
} | ||
const { server } = options; | ||
if (server && !server.listening) { | ||
throw new HotClientError( | ||
'`options.server` must be a running/listening net.Server instance' | ||
); | ||
} else if (server) { | ||
if ( | ||
server && | ||
server instanceof HttpsServer && | ||
typeof options.https === 'undefined' | ||
) { | ||
options.https = true; | ||
} | ||
if (server && server.listening) { | ||
options.webSocket = { | ||
@@ -75,8 +94,7 @@ host: server.address().address, | ||
}; | ||
if (server instanceof HttpsServer && typeof options.https === 'undefined') { | ||
options.https = true; | ||
} | ||
} else { | ||
options.webSocket = { host: options.host.client, port: options.port }; | ||
options.webSocket = { | ||
host: options.host.client, | ||
port: options.port.client, | ||
}; | ||
} | ||
@@ -83,0 +101,0 @@ |
@@ -7,3 +7,10 @@ const stringify = require('json-stringify-safe'); | ||
const { host, log, port, server } = options; | ||
const wssOptions = server ? { server } : { host: host.server, port }; | ||
const wssOptions = server | ||
? { server } | ||
: { host: host.server, port: port.server }; | ||
if (server && !server.listening) { | ||
server.listen(port.server, host.server); | ||
} | ||
const wss = new WebSocket.Server(wssOptions); | ||
@@ -91,3 +98,3 @@ | ||
if (options.server) { | ||
if (options.server && options.server.listening) { | ||
const addr = options.server.address(); | ||
@@ -94,0 +101,0 @@ server.host = addr.address; |
{ | ||
"name": "webpack-hot-client", | ||
"version": "4.0.4", | ||
"version": "4.1.0-beta.1", | ||
"publishConfig": { | ||
"tag": "beta" | ||
}, | ||
"description": "A client for enabling, and interacting with, webpack Hot Module Replacement", | ||
@@ -5,0 +8,0 @@ "license": "MIT", |
@@ -150,3 +150,4 @@ <div align="center"> | ||
the host of the server the module is used with, the module may not function | ||
properly. If the `server` option is defined, this option is ignored. | ||
properly. If the `server` option is defined, and the server has been instructed | ||
to listen, this option is ignored. | ||
@@ -185,2 +186,6 @@ If using the module in a specialized environment, you may choose to specify an | ||
_Note: When using a self-signed certificate on Firefox, you must add a "Server | ||
Exception" for `localhost:{port}` where `{port}` is either the `port` or the | ||
`port.server` option for secure `WebSocket` to work correctly._ | ||
##### logLevel | ||
@@ -203,3 +208,3 @@ | ||
Type: `Number` | ||
Type: `Number|Object` | ||
Default: `0` | ||
@@ -209,4 +214,13 @@ | ||
will allocate a port. If a different port is chosen, the consumer of the module | ||
must ensure that the port is free before hand. | ||
must ensure that the port is free before hand. If the `server` option is defined, | ||
and the server has been instructed to listen, this option is ignored. | ||
If using the module in a specialized environment, you may choose to specify an | ||
`object` to define `client` and `server` port separately. The `object` value | ||
should match `{ client: <Number>, server: <Number> }`. Be aware that the `client` | ||
port will be used _in the browser_ by `WebSockets`. You should not use this | ||
option in this way unless _you know what you're doing._ Using a mismatched | ||
`client` and `server` port will be **unsupported by the project** as the behavior | ||
in the browser can be unpredictable and is specific to a particular environment. | ||
##### reload | ||
@@ -213,0 +227,0 @@ |
@@ -44,3 +44,18 @@ { | ||
"port": { | ||
"type": "integer" | ||
"anyOf": [ | ||
{ | ||
"type": "integer" | ||
}, | ||
{ | ||
"properties": { | ||
"client": { | ||
"type": "integer" | ||
}, | ||
"server": { | ||
"type": "integer" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
] | ||
}, | ||
@@ -47,0 +62,0 @@ "reload": { |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
42692
842
309
1