Skip to content

Commit deb9394

Browse files
authored
feat!: rename webpack env vars to rspack (#108)
1 parent ed00dfd commit deb9394

5 files changed

Lines changed: 23 additions & 23 deletions

File tree

src/server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,15 @@ class Server<
318318
const { default: pRetry } = await import('p-retry');
319319
const getPort = require('./getPort');
320320
const basePort =
321-
typeof process.env.WEBPACK_DEV_SERVER_BASE_PORT !== 'undefined'
322-
? Number.parseInt(process.env.WEBPACK_DEV_SERVER_BASE_PORT, 10)
321+
typeof process.env.RSPACK_DEV_SERVER_BASE_PORT !== 'undefined'
322+
? Number.parseInt(process.env.RSPACK_DEV_SERVER_BASE_PORT, 10)
323323
: 8080;
324324

325325
// Try to find unused port and listen on it for 3 times,
326326
// if port is not specified in options.
327327
const defaultPortRetry =
328-
typeof process.env.WEBPACK_DEV_SERVER_PORT_RETRY !== 'undefined'
329-
? Number.parseInt(process.env.WEBPACK_DEV_SERVER_PORT_RETRY, 10)
328+
typeof process.env.RSPACK_DEV_SERVER_PORT_RETRY !== 'undefined'
329+
? Number.parseInt(process.env.RSPACK_DEV_SERVER_PORT_RETRY, 10)
330330
: 3;
331331

332332
return pRetry(() => getPort(basePort, host), {

tests/e2e/api.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ describe('API', () => {
350350
let devServerPort;
351351

352352
afterEach(() => {
353-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = undefined;
354-
process.env.WEBPACK_DEV_SERVER_PORT_RETRY = undefined;
353+
process.env.RSPACK_DEV_SERVER_BASE_PORT = undefined;
354+
process.env.RSPACK_DEV_SERVER_PORT_RETRY = undefined;
355355

356356
return dummyServers
357357
.reduce(
@@ -372,7 +372,7 @@ describe('API', () => {
372372
});
373373

374374
function createDummyServers(n) {
375-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = 60000;
375+
process.env.RSPACK_DEV_SERVER_BASE_PORT = 60000;
376376

377377
return (Array.isArray(n) ? n : [...new Array(n)]).reduce(
378378
(p, _, i) =>
@@ -400,7 +400,7 @@ describe('API', () => {
400400
it('should return the port when the port is specified', async () => {
401401
const retryCount = 1;
402402

403-
process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount;
403+
process.env.RSPACK_DEV_SERVER_PORT_RETRY = retryCount;
404404

405405
const freePort = await Server.getFreePort(9082);
406406

@@ -410,7 +410,7 @@ describe('API', () => {
410410
it('should return the port when the port is `null`', async () => {
411411
const retryCount = 2;
412412

413-
process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount;
413+
process.env.RSPACK_DEV_SERVER_PORT_RETRY = retryCount;
414414

415415
await createDummyServers(retryCount);
416416

@@ -449,7 +449,7 @@ describe('API', () => {
449449
it('should return the port when the port is undefined', async () => {
450450
const retryCount = 3;
451451

452-
process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount;
452+
process.env.RSPACK_DEV_SERVER_PORT_RETRY = retryCount;
453453

454454
await createDummyServers(retryCount);
455455

@@ -489,7 +489,7 @@ describe('API', () => {
489489
it('should retry finding the port for up to defaultPortRetry times (number)', async () => {
490490
const retryCount = 4;
491491

492-
process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount;
492+
process.env.RSPACK_DEV_SERVER_PORT_RETRY = retryCount;
493493

494494
await createDummyServers(retryCount);
495495

@@ -528,7 +528,7 @@ describe('API', () => {
528528
it('should retry finding the port for up to defaultPortRetry times (string)', async () => {
529529
const retryCount = 5;
530530

531-
process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount;
531+
process.env.RSPACK_DEV_SERVER_PORT_RETRY = retryCount;
532532

533533
await createDummyServers(retryCount);
534534

@@ -567,7 +567,7 @@ describe('API', () => {
567567
it('should retry finding the port when serial ports are busy', async () => {
568568
const busyPorts = [60000, 60001, 60002, 60003, 60004, 60005];
569569

570-
process.env.WEBPACK_DEV_SERVER_PORT_RETRY = 1000;
570+
process.env.RSPACK_DEV_SERVER_PORT_RETRY = 1000;
571571

572572
await createDummyServers(busyPorts);
573573

@@ -611,7 +611,7 @@ describe('API', () => {
611611
() => () => Promise.reject(new Error('busy')),
612612
);
613613

614-
process.env.WEBPACK_DEV_SERVER_PORT_RETRY = 1;
614+
process.env.RSPACK_DEV_SERVER_PORT_RETRY = 1;
615615

616616
const { RspackDevServer: Server } = require('@rspack/dev-server');
617617

tests/e2e/host.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe('host', () => {
200200
it(`should work using "${host}" host and "auto" port`, async () => {
201201
const compiler = rspack(config);
202202

203-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = port;
203+
process.env.RSPACK_DEV_SERVER_BASE_PORT = port;
204204

205205
const devServerOptions = { port: 'auto' };
206206

@@ -260,7 +260,7 @@ describe('host', () => {
260260

261261
expect(pageErrors).toMatchSnapshot('page errors');
262262
} finally {
263-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = undefined;
263+
process.env.RSPACK_DEV_SERVER_BASE_PORT = undefined;
264264

265265
await browser.close();
266266
await server.stop();

tests/e2e/port.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ describe('port', () => {
2828
testedPort === '<not-specified>' ||
2929
typeof testedPort === 'undefined'
3030
) {
31-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = port;
31+
process.env.RSPACK_DEV_SERVER_BASE_PORT = port;
3232
usedPort = port;
3333
} else if (testedPort === 'auto') {
34-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = port;
34+
process.env.RSPACK_DEV_SERVER_BASE_PORT = port;
3535
devServerOptions.port = testedPort;
3636
usedPort = port;
3737
} else {
@@ -100,7 +100,7 @@ describe('port', () => {
100100
testedPort === '<not-specified>' ||
101101
typeof testedPort === 'undefined'
102102
) {
103-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = undefined;
103+
process.env.RSPACK_DEV_SERVER_BASE_PORT = undefined;
104104
}
105105
});
106106
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ describe('web socket server URL', () => {
306306
});
307307

308308
it(`should work behind proxy, when the "host" option is "local-ip" and the "port" option is "auto" ("${webSocketServer}")`, async () => {
309-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = 40000;
309+
process.env.RSPACK_DEV_SERVER_BASE_PORT = 40000;
310310

311311
const proxyHost = Server.internalIPSync('v4');
312312
const proxyPort = port2;
@@ -404,7 +404,7 @@ describe('web socket server URL', () => {
404404
await browser.close();
405405
await server.stop();
406406

407-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = undefined;
407+
process.env.RSPACK_DEV_SERVER_BASE_PORT = undefined;
408408
}
409409
});
410410

@@ -2361,7 +2361,7 @@ describe('web socket server URL', () => {
23612361
});
23622362

23632363
it(`should work when "port" option is "auto" ("${webSocketServer}")`, async () => {
2364-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = 50000;
2364+
process.env.RSPACK_DEV_SERVER_BASE_PORT = 50000;
23652365

23662366
const compiler = rspack(config);
23672367
const devServerOptions = {
@@ -2430,7 +2430,7 @@ describe('web socket server URL', () => {
24302430
await browser.close();
24312431
await server.stop();
24322432

2433-
process.env.WEBPACK_DEV_SERVER_BASE_PORT = undefined;
2433+
process.env.RSPACK_DEV_SERVER_BASE_PORT = undefined;
24342434
}
24352435
});
24362436

0 commit comments

Comments
 (0)