Skip to content
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

feat: add sockProtocol option to overlay #242

Merged
merged 8 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ interface ErrorOverlayOptions {
sockHost?: string;
sockPath?: string;
sockPort?: number;
sockProtocol?: 'http' | 'https';
sockProtocol?: 'http' | 'https' | 'ws' | 'wss';
useLegacyWDSSockets?: boolean;
}
```
Expand Down Expand Up @@ -190,7 +190,7 @@ Useful if you set `devServer.sockPath` to something other than `/sockjs-node`.

Default: parsed from current url

Type: `http` or `https`
Type: `http`, `https`, `ws`, `wss`
patrikholcak marked this conversation as resolved.
Show resolved Hide resolved

**This is relevant for `webpack-dev-server` only.**

Expand Down
2 changes: 1 addition & 1 deletion lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"sockHost": { "type": "string" },
"sockPath": { "type": "string" },
"sockPort": { "type": "number", "minimum": 0 },
"sockProtocol": { "enum": ["http", "https"] },
"sockProtocol": { "enum": ["http", "https", "ws", "wss"] },
"useLegacyWDSSockets": { "type": "boolean" }
}
},
Expand Down
2 changes: 1 addition & 1 deletion lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @property {import('type-fest').LiteralUnion<'wds' | 'whm' | 'wps' | false, string>} [sockIntegration] Path to a JS file that sets up the Webpack socket integration.
* @property {string} [sockPath] The socket path to use (WDS only).
* @property {number} [sockPort] The socket port to use (WDS only).
* @property {'http' | 'https'} [sockProtocol] The socket protocol to use (WDS only).
* @property {'http' | 'https' | 'ws' | 'wss'} [sockProtocol] The socket protocol to use (WDS only).
* @property {boolean} [useLegacyWDSSockets] Uses a custom SocketJS implementation for older versions of webpack-dev-server.
*/

Expand Down
2 changes: 1 addition & 1 deletion sockets/utils/getSocketUrlParts.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function getSocketUrlParts(resourceQuery) {

// Make sure the protocol from resource query has a trailing colon
if (parsedQuery.sockProtocol) {
protocol = url.format({ protocol: parsedQuery.sockProtocol });
protocol = parsedQuery.sockProtocol + ':';
}

return {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/validateOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,15 @@ describe('validateOptions', () => {
}).not.toThrow();
});

it('should reject "overlay.sockProtocol" when it is not "http" or "https"', () => {
it('should reject "overlay.sockProtocol" when it is not "http", "https", "ws" nor "wss"', () => {
expect(() => {
new ReactRefreshPlugin({
overlay: { sockProtocol: true },
});
}).toThrowErrorMatchingInlineSnapshot(`
"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.
- options.overlay.sockProtocol should be one of these:
\\"http\\" | \\"https\\""
\\"http\\" | \\"https\\" | \\"ws\\" | \\"wss\\""
`);
});

Expand Down
4 changes: 2 additions & 2 deletions types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type ErrorOverlayOptions = {
/**
* The socket protocol to use (WDS only).
*/
sockProtocol?: 'http' | 'https';
sockProtocol?: 'http' | 'https' | 'ws' | 'wss';
/**
* Uses a custom SocketJS implementation for older versions of webpack-dev-server.
*/
Expand All @@ -48,7 +48,7 @@ export type NormalizedErrorOverlayOptions = {
/**
* The socket protocol to use (WDS only).
*/
sockProtocol?: 'http' | 'https';
sockProtocol?: 'http' | 'https' | 'ws' | 'wss';
/**
* Uses a custom SocketJS implementation for older versions of webpack-dev-server.
*/
Expand Down