Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"search.useIgnoreFiles": true,
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,13 @@
"webpack-merge": "^6.0.1"
},
"dependencies": {
"@types/bonjour": "^3.5.13",
"@types/connect-history-api-fallback": "^1.5.4",
"@types/express": "^4.17.25",
"@types/express-serve-static-core": "^4.17.21",
"@types/serve-index": "^1.9.4",
"@types/serve-static": "^1.15.5",
"@types/sockjs": "^0.3.36",
"@types/ws": "^8.5.10",
"bonjour-service": "^1.2.1",
"chokidar": "^3.6.0",
"compression": "^1.8.1",
"connect-history-api-fallback": "^2.0.0",
Expand Down
48 changes: 0 additions & 48 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type {
BonjourOptions,
ClientConfiguration,
ConnectHistoryApiFallbackOptions,
DevServer,
Expand All @@ -23,7 +22,6 @@ export interface ResolvedDevServer extends DevServer {
proxy: Required<DevServer['proxy']>;
client: ClientConfiguration;
allowedHosts: 'auto' | string[] | 'all';
bonjour: false | Record<string, never> | BonjourOptions;
compress: boolean;
historyApiFallback: false | ConnectHistoryApiFallbackOptions;
server: ServerConfiguration;
Expand Down
59 changes: 0 additions & 59 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import type {
Port,
DevMiddlewareOptions,
ConnectHistoryApiFallbackOptions,
BonjourOptions,
WatchFiles,
Static,
ServerType,
Expand All @@ -42,7 +41,6 @@ import type {
EXPECTED_ANY,
RequestHandler,
Socket,
Bonjour,
WebSocketServerImplementation,
Stats,
MultiStats,
Expand Down Expand Up @@ -89,7 +87,6 @@ export interface Configuration<
compress?: boolean;
allowedHosts?: 'auto' | 'all' | string | string[];
historyApiFallback?: boolean | ConnectHistoryApiFallbackOptions;
bonjour?: boolean | Record<string, never> | BonjourOptions;
watchFiles?: string | string[] | WatchFiles | Array<string | WatchFiles>;
static?: boolean | string | Static | Array<string | Static>;
server?: ServerType<A, S> | ServerConfiguration<A, S>;
Expand Down Expand Up @@ -177,7 +174,6 @@ class Server<
sockets: Socket[];
currentHash: string | undefined;
isTlsServer = false;
bonjour: Bonjour | undefined;
webSocketServer: WebSocketServerImplementation | null | undefined;
middleware:
| import('webpack-dev-middleware').API<Request, Response>
Expand Down Expand Up @@ -801,12 +797,6 @@ class Server<
options.allowedHosts = 'all';
}

if (typeof options.bonjour === 'undefined') {
options.bonjour = false;
} else if (typeof options.bonjour === 'boolean') {
options.bonjour = options.bonjour ? {} : false;
}

if (
typeof options.client === 'undefined' ||
(typeof options.client === 'object' && options.client !== null)
Expand Down Expand Up @@ -2401,31 +2391,6 @@ class Server<
);
}

runBonjour(): void {
const { Bonjour } = require('bonjour-service');

const type = this.isTlsServer ? 'https' : 'http';

this.bonjour = new Bonjour();
this.bonjour?.publish({
name: `Rspack Dev Server ${os.hostname()}:${this.options.port}`,
port: this.options.port as number,
type,
subtypes: ['rspack'],
...(this.options.bonjour as Partial<BonjourOptions>),
});
}

stopBonjour(callback: () => void = () => {}) {
this.bonjour?.unpublishAll(() => {
this.bonjour?.destroy();

if (callback) {
callback();
}
});
}

async logStatus() {
const server = this.server as S;

Expand Down Expand Up @@ -2520,18 +2485,6 @@ class Server<
await this.openBrowser(openTarget);
}
}

if (this.options.bonjour) {
const bonjourProtocol =
(this.options.bonjour as BonjourOptions | undefined)?.type ||
this.isTlsServer
? 'https'
: 'http';

this.logger.info(
`Broadcasting "${bonjourProtocol}" with subtype of "rspack" via ZeroConf DNS (Bonjour)`,
);
}
}

setHeaders(req: Request, res: Response, next: NextFunction) {
Expand Down Expand Up @@ -2892,10 +2845,6 @@ class Server<
this.createWebSocketServer();
}

if (this.options.bonjour) {
this.runBonjour();
}

await this.logStatus();

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

async stop(): Promise<void> {
if (this.bonjour) {
await new Promise<void>((resolve) => {
this.stopBonjour(() => {
resolve();
});
});
}

this.webSocketProxies = [];

await Promise.all(this.staticWatchers.map((watcher) => watcher.close()));
Expand Down
2 changes: 0 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export type {
StatsCompilation,
StatsOptions,
} from '@rspack/core';
import type { Bonjour, Service as BonjourOptions } from 'bonjour-service';
export type { Bonjour, BonjourOptions };
import type { FSWatcher, WatchOptions } from 'chokidar';
export type { FSWatcher, WatchOptions };
import type { Options as ConnectHistoryApiFallbackOptions } from 'connect-history-api-fallback';
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/__snapshots__/api.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`API > Server.checkHostHeader > should allow URLs with scheme for checki

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

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"`;
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"`;

exports[`API > Server.getFreePort > should retry finding the port for up to defaultPortRetry times (number) > console messages 1`] = `
[
Expand Down
49 changes: 0 additions & 49 deletions tests/e2e/__snapshots__/bonjour.test.js.snap.webpack5

This file was deleted.

Loading
Loading