Skip to content

Commit d82ff93

Browse files
authored
feat!: remove bonjour feature (#87)
1 parent bf3e46f commit d82ff93

12 files changed

Lines changed: 12 additions & 515 deletions

.vscode/settings.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"search.useIgnoreFiles": true,
33
"[json]": {
4-
"editor.defaultFormatter": "biomejs.biome"
4+
"editor.defaultFormatter": "esbenp.prettier-vscode"
55
},
66
"[typescript]": {
7-
"editor.defaultFormatter": "biomejs.biome"
7+
"editor.defaultFormatter": "esbenp.prettier-vscode"
88
},
99
"[javascript]": {
10-
"editor.defaultFormatter": "biomejs.biome"
10+
"editor.defaultFormatter": "esbenp.prettier-vscode"
1111
},
1212
"[javascriptreact]": {
13-
"editor.defaultFormatter": "biomejs.biome"
13+
"editor.defaultFormatter": "esbenp.prettier-vscode"
1414
},
1515
"[css]": {
16-
"editor.defaultFormatter": "biomejs.biome"
16+
"editor.defaultFormatter": "esbenp.prettier-vscode"
1717
}
1818
}

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,13 @@
9797
"webpack-merge": "^6.0.1"
9898
},
9999
"dependencies": {
100-
"@types/bonjour": "^3.5.13",
101100
"@types/connect-history-api-fallback": "^1.5.4",
102101
"@types/express": "^4.17.25",
103102
"@types/express-serve-static-core": "^4.17.21",
104103
"@types/serve-index": "^1.9.4",
105104
"@types/serve-static": "^1.15.5",
106105
"@types/sockjs": "^0.3.36",
107106
"@types/ws": "^8.5.10",
108-
"bonjour-service": "^1.2.1",
109107
"chokidar": "^3.6.0",
110108
"compression": "^1.8.1",
111109
"connect-history-api-fallback": "^2.0.0",

pnpm-lock.yaml

Lines changed: 0 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type {
2-
BonjourOptions,
32
ClientConfiguration,
43
ConnectHistoryApiFallbackOptions,
54
DevServer,
@@ -23,7 +22,6 @@ export interface ResolvedDevServer extends DevServer {
2322
proxy: Required<DevServer['proxy']>;
2423
client: ClientConfiguration;
2524
allowedHosts: 'auto' | string[] | 'all';
26-
bonjour: false | Record<string, never> | BonjourOptions;
2725
compress: boolean;
2826
historyApiFallback: false | ConnectHistoryApiFallbackOptions;
2927
server: ServerConfiguration;

src/server.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import type {
2424
Port,
2525
DevMiddlewareOptions,
2626
ConnectHistoryApiFallbackOptions,
27-
BonjourOptions,
2827
WatchFiles,
2928
Static,
3029
ServerType,
@@ -42,7 +41,6 @@ import type {
4241
EXPECTED_ANY,
4342
RequestHandler,
4443
Socket,
45-
Bonjour,
4644
WebSocketServerImplementation,
4745
Stats,
4846
MultiStats,
@@ -89,7 +87,6 @@ export interface Configuration<
8987
compress?: boolean;
9088
allowedHosts?: 'auto' | 'all' | string | string[];
9189
historyApiFallback?: boolean | ConnectHistoryApiFallbackOptions;
92-
bonjour?: boolean | Record<string, never> | BonjourOptions;
9390
watchFiles?: string | string[] | WatchFiles | Array<string | WatchFiles>;
9491
static?: boolean | string | Static | Array<string | Static>;
9592
server?: ServerType<A, S> | ServerConfiguration<A, S>;
@@ -177,7 +174,6 @@ class Server<
177174
sockets: Socket[];
178175
currentHash: string | undefined;
179176
isTlsServer = false;
180-
bonjour: Bonjour | undefined;
181177
webSocketServer: WebSocketServerImplementation | null | undefined;
182178
middleware:
183179
| import('webpack-dev-middleware').API<Request, Response>
@@ -801,12 +797,6 @@ class Server<
801797
options.allowedHosts = 'all';
802798
}
803799

804-
if (typeof options.bonjour === 'undefined') {
805-
options.bonjour = false;
806-
} else if (typeof options.bonjour === 'boolean') {
807-
options.bonjour = options.bonjour ? {} : false;
808-
}
809-
810800
if (
811801
typeof options.client === 'undefined' ||
812802
(typeof options.client === 'object' && options.client !== null)
@@ -2401,31 +2391,6 @@ class Server<
24012391
);
24022392
}
24032393

2404-
runBonjour(): void {
2405-
const { Bonjour } = require('bonjour-service');
2406-
2407-
const type = this.isTlsServer ? 'https' : 'http';
2408-
2409-
this.bonjour = new Bonjour();
2410-
this.bonjour?.publish({
2411-
name: `Rspack Dev Server ${os.hostname()}:${this.options.port}`,
2412-
port: this.options.port as number,
2413-
type,
2414-
subtypes: ['rspack'],
2415-
...(this.options.bonjour as Partial<BonjourOptions>),
2416-
});
2417-
}
2418-
2419-
stopBonjour(callback: () => void = () => {}) {
2420-
this.bonjour?.unpublishAll(() => {
2421-
this.bonjour?.destroy();
2422-
2423-
if (callback) {
2424-
callback();
2425-
}
2426-
});
2427-
}
2428-
24292394
async logStatus() {
24302395
const server = this.server as S;
24312396

@@ -2520,18 +2485,6 @@ class Server<
25202485
await this.openBrowser(openTarget);
25212486
}
25222487
}
2523-
2524-
if (this.options.bonjour) {
2525-
const bonjourProtocol =
2526-
(this.options.bonjour as BonjourOptions | undefined)?.type ||
2527-
this.isTlsServer
2528-
? 'https'
2529-
: 'http';
2530-
2531-
this.logger.info(
2532-
`Broadcasting "${bonjourProtocol}" with subtype of "rspack" via ZeroConf DNS (Bonjour)`,
2533-
);
2534-
}
25352488
}
25362489

25372490
setHeaders(req: Request, res: Response, next: NextFunction) {
@@ -2892,10 +2845,6 @@ class Server<
28922845
this.createWebSocketServer();
28932846
}
28942847

2895-
if (this.options.bonjour) {
2896-
this.runBonjour();
2897-
}
2898-
28992848
await this.logStatus();
29002849

29012850
if (typeof this.options.onListening === 'function') {
@@ -2910,14 +2859,6 @@ class Server<
29102859
}
29112860

29122861
async stop(): Promise<void> {
2913-
if (this.bonjour) {
2914-
await new Promise<void>((resolve) => {
2915-
this.stopBonjour(() => {
2916-
resolve();
2917-
});
2918-
});
2919-
}
2920-
29212862
this.webSocketProxies = [];
29222863

29232864
await Promise.all(this.staticWatchers.map((watcher) => watcher.close()));

src/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export type {
1616
StatsCompilation,
1717
StatsOptions,
1818
} from '@rspack/core';
19-
import type { Bonjour, Service as BonjourOptions } from 'bonjour-service';
20-
export type { Bonjour, BonjourOptions };
2119
import type { FSWatcher, WatchOptions } from 'chokidar';
2220
export type { FSWatcher, WatchOptions };
2321
import type { Options as ConnectHistoryApiFallbackOptions } from 'connect-history-api-fallback';

tests/e2e/__snapshots__/api.test.js.snap.webpack5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exports[`API > Server.checkHostHeader > should allow URLs with scheme for checki
2828

2929
exports[`API > Server.checkHostHeader > should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object > response status 1`] = `200`;
3030

31-
exports[`API > Server.checkHostHeader > should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object > web socket URL 1`] = `"ws://test.host:8158/ws"`;
31+
exports[`API > Server.checkHostHeader > should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object > web socket URL 1`] = `"ws://test.host:8156/ws"`;
3232

3333
exports[`API > Server.getFreePort > should retry finding the port for up to defaultPortRetry times (number) > console messages 1`] = `
3434
[

tests/e2e/__snapshots__/bonjour.test.js.snap.webpack5

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)