Skip to content

Commit 09bdda5

Browse files
authored
feat!: remove internalIP methods (#5625)
1 parent b550a70 commit 09bdda5

10 files changed

Lines changed: 33 additions & 74 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# internalIP(family: "v4" | "v6")
1+
# findIp(family: "v4" | "v6")
22

3-
Returns the internal IP address asynchronously.
3+
Returns the internal IP address.
44

55
```js
66
const WebpackDevServer = require("webpack-dev-server");
77

88
const logInternalIPs = async () => {
9-
const localIPv4 = await WebpackDevServer.internalIP("v4");
10-
const localIPv6 = await WebpackDevServer.internalIP("v6");
9+
const localIPv4 = WebpackDevServer.findIp("v4", false);
10+
const localIPv6 = WebpackDevServer.findIp("v6", false);
1111

1212
console.log("Local IPv4 address:", localIPv4);
1313
console.log("Local IPv6 address:", localIPv6);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const WebpackDevServer = require("../../../lib/Server");
44

55
const logInternalIPs = async () => {
6-
const localIPv4 = await WebpackDevServer.internalIP("v4");
7-
const localIPv6 = await WebpackDevServer.internalIP("v6");
6+
const localIPv4 = WebpackDevServer.findIp("v4", false);
7+
const localIPv6 = WebpackDevServer.findIp("v6", false);
88

99
console.log("Local IPv4 address:", localIPv4);
1010
console.log("Local IPv6 address:", localIPv6);

examples/api/internal-ip-sync/README.md

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

examples/api/internal-ip-sync/app.js

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

lib/Server.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -475,24 +475,6 @@ class Server {
475475
}
476476
}
477477

478-
// TODO remove me in the next major release, we have `findIp`
479-
/**
480-
* @param {"v4" | "v6"} family family
481-
* @returns {Promise<string | undefined>} internal API
482-
*/
483-
static async internalIP(family) {
484-
return Server.findIp(family, false);
485-
}
486-
487-
// TODO remove me in the next major release, we have `findIp`
488-
/**
489-
* @param {"v4" | "v6"} family family
490-
* @returns {string | undefined} internal IP
491-
*/
492-
static internalIPSync(family) {
493-
return Server.findIp(family, false);
494-
}
495-
496478
/**
497479
* @param {Host} hostname hostname
498480
* @returns {Promise<string>} resolved hostname

migration-v6.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Migration guide
2+
3+
This document serves as a migration guide for `webpack-dev-server@6.0.0`.
4+
5+
## Deprecations
6+
7+
- The static methods `internalIP` and `internalIPSync` were removed. Use `findIp` instead.
8+
9+
v4:
10+
11+
```js
12+
const ip = Server.internalIP("v4");
13+
```
14+
15+
v5:
16+
17+
```js
18+
const ip = Server.findIp("v4", true);
19+
```

test/e2e/allowed-hosts.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ describe("allowed hosts", () => {
16571657
});
16581658

16591659
it("should always allow value from the `host` options if options.allowedHosts is auto", async () => {
1660-
const networkIP = Server.internalIPSync("v4");
1660+
const networkIP = Server.findIp("v4", false);
16611661
const options = {
16621662
host: networkIP,
16631663
allowedHosts: "auto",

test/e2e/web-socket-server-url.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe("web socket server URL", () => {
113113
it(`should work behind proxy, when hostnames are different and ports are same ("${webSocketServer}")`, async () => {
114114
const devServerHost = "127.0.0.1";
115115
const devServerPort = port1;
116-
const proxyHost = Server.internalIPSync("v4");
116+
const proxyHost = Server.findIp("v4", false);
117117
const proxyPort = port1;
118118

119119
const compiler = webpack(config);
@@ -209,7 +209,7 @@ describe("web socket server URL", () => {
209209
it(`should work behind proxy, when hostnames are different and ports are different ("${webSocketServer}")`, async () => {
210210
const devServerHost = "localhost";
211211
const devServerPort = port1;
212-
const proxyHost = Server.internalIPSync("v4");
212+
const proxyHost = Server.findIp("v4", false);
213213
const proxyPort = port2;
214214

215215
const compiler = webpack(config);
@@ -310,7 +310,7 @@ describe("web socket server URL", () => {
310310
it(`should work behind proxy, when the "host" option is "local-ip" and the "port" option is "auto" ("${webSocketServer}")`, async () => {
311311
process.env.WEBPACK_DEV_SERVER_BASE_PORT = 40000;
312312

313-
const proxyHost = Server.internalIPSync("v4");
313+
const proxyHost = Server.findIp("v4", false);
314314
const proxyPort = port2;
315315

316316
const compiler = webpack(config);
@@ -2006,7 +2006,7 @@ describe("web socket server URL", () => {
20062006
});
20072007

20082008
it(`should work when "host" option is IPv4 ("${webSocketServer}")`, async () => {
2009-
const hostname = Server.internalIPSync("v4");
2009+
const hostname = Server.findIp("v4", false);
20102010
const compiler = webpack(config);
20112011
const devServerOptions = {
20122012
webSocketServer,
@@ -2074,7 +2074,7 @@ describe("web socket server URL", () => {
20742074
});
20752075

20762076
it(`should work when "host" option is "local-ip" ("${webSocketServer}")`, async () => {
2077-
const hostname = Server.internalIPSync("v4");
2077+
const hostname = Server.findIp("v4", false);
20782078
const compiler = webpack(config);
20792079
const devServerOptions = {
20802080
webSocketServer,
@@ -2143,7 +2143,7 @@ describe("web socket server URL", () => {
21432143
});
21442144

21452145
it(`should work when "host" option is "local-ipv4" ("${webSocketServer}")`, async () => {
2146-
const hostname = Server.internalIPSync("v4");
2146+
const hostname = Server.findIp("v4", false);
21472147
const compiler = webpack(config);
21482148
const devServerOptions = {
21492149
webSocketServer,

test/server/open-option.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Server = require("../../lib/Server");
55
const config = require("../fixtures/simple-config/webpack.config");
66
const port = require("../ports-map")["open-option"];
77

8-
const internalIPv4 = Server.internalIPSync("v4");
8+
const internalIPv4 = Server.findIp("v4", false);
99

1010
let open;
1111

types/lib/Server.d.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,16 +1141,6 @@ declare class Server<
11411141
gatewayOrFamily: string,
11421142
isInternal?: boolean | undefined,
11431143
): string | undefined;
1144-
/**
1145-
* @param {"v4" | "v6"} family family
1146-
* @returns {Promise<string | undefined>} internal API
1147-
*/
1148-
static internalIP(family: "v4" | "v6"): Promise<string | undefined>;
1149-
/**
1150-
* @param {"v4" | "v6"} family family
1151-
* @returns {string | undefined} internal IP
1152-
*/
1153-
static internalIPSync(family: "v4" | "v6"): string | undefined;
11541144
/**
11551145
* @param {Host} hostname hostname
11561146
* @returns {Promise<string>} resolved hostname

0 commit comments

Comments
 (0)