Skip to content

Commit 78ebe7f

Browse files
authored
refactor: use bonjour-service (#4310)
* refactor: use `bonjour-service` * test: refactor * refactor: code * test: fix * fix: improve types
1 parent 537eeb2 commit 78ebe7f

File tree

5 files changed

+390
-762
lines changed

5 files changed

+390
-762
lines changed

lib/Server.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const schema = require("./options.json");
2929
/** @typedef {import("chokidar").WatchOptions} WatchOptions */
3030
/** @typedef {import("chokidar").FSWatcher} FSWatcher */
3131
/** @typedef {import("connect-history-api-fallback").Options} ConnectHistoryApiFallbackOptions */
32-
/** @typedef {import("bonjour").Bonjour} Bonjour */
33-
/** @typedef {import("bonjour").BonjourOptions} BonjourOptions */
32+
/** @typedef {import("bonjour-service").Bonjour} Bonjour */
33+
/** @typedef {import("bonjour-service").Service} BonjourOptions */
3434
/** @typedef {import("http-proxy-middleware").RequestHandler} RequestHandler */
3535
/** @typedef {import("http-proxy-middleware").Options} HttpProxyMiddlewareOptions */
3636
/** @typedef {import("http-proxy-middleware").Filter} HttpProxyMiddlewareOptionsFilter */
@@ -188,7 +188,7 @@ const schema = require("./options.json");
188188
* @property {"auto" | "all" | string | string[]} [allowedHosts]
189189
* @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
190190
* @property {boolean} [setupExitSignals]
191-
* @property {boolean | BonjourOptions} [bonjour]
191+
* @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
192192
* @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
193193
* @property {boolean | string | Static | Array<string | Static>} [static]
194194
* @property {boolean | ServerOptions} [https]
@@ -2594,14 +2594,18 @@ class Server {
25942594
* @returns {void}
25952595
*/
25962596
runBonjour() {
2597+
const { Bonjour } = require("bonjour-service");
25972598
/**
25982599
* @private
2599-
* @type {import("bonjour").Bonjour | undefined}
2600+
* @type {Bonjour | undefined}
26002601
*/
2601-
this.bonjour = require("bonjour")();
2602+
this.bonjour = new Bonjour();
26022603
this.bonjour.publish({
2604+
// @ts-expect-error
26032605
name: `Webpack Dev Server ${os.hostname()}:${this.options.port}`,
2606+
// @ts-expect-error
26042607
port: /** @type {number} */ (this.options.port),
2608+
// @ts-expect-error
26052609
type:
26062610
/** @type {ServerConfiguration} */
26072611
(this.options.server).type === "http" ? "http" : "https",

0 commit comments

Comments
 (0)