Skip to content

Commit 527bc3a

Browse files
authored
fix: move compression and p-retry to dev dependencies (#136)
1 parent 248ef57 commit 527bc3a

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@
5050
"@types/serve-static": "^2.2.0",
5151
"@types/ws": "^8.18.1",
5252
"chokidar": "^3.6.0",
53-
"compression": "^1.8.1",
5453
"connect-history-api-fallback": "^2.0.0",
5554
"express": "^5.2.1",
5655
"http-proxy-middleware": "^3.0.5",
5756
"ipaddr.js": "^2.3.0",
58-
"p-retry": "^7.1.1",
5957
"serve-index": "^1.9.2",
6058
"webpack-dev-middleware": "^7.4.5",
6159
"ws": "^8.19.0"
@@ -74,6 +72,7 @@
7472
"@types/node-forge": "^1.3.14",
7573
"@types/trusted-types": "^2.0.7",
7674
"@types/ws": "8.18.1",
75+
"compression": "^1.8.1",
7776
"connect": "^3.7.0",
7877
"cross-env": "^10.1.0",
7978
"css-loader": "^7.1.4",
@@ -82,6 +81,7 @@
8281
"launch-editor": "^2.13.1",
8382
"nano-staged": "^0.9.0",
8483
"open": "^11.0.0",
84+
"p-retry": "^7.1.1",
8585
"prettier": "3.8.1",
8686
"puppeteer": "^24.37.5",
8787
"react-refresh": "0.18.0",

pnpm-lock.yaml

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

src/server.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as path from 'node:path';
1515
import * as url from 'node:url';
1616
import * as util from 'node:util';
1717
import ipaddr from 'ipaddr.js';
18+
import { getPort } from './getPort';
1819
import { WebsocketServer } from './servers/WebsocketServer';
1920
import type {
2021
AddressInfo,
@@ -330,8 +331,9 @@ class Server<
330331
return port;
331332
}
332333

333-
const { default: pRetry } = await import('p-retry');
334-
const { getPort } = await import('./getPort');
334+
const { default: pRetry } = await import(
335+
/* webpackChunkName: "p-retry" */ 'p-retry'
336+
);
335337
const basePort =
336338
typeof process.env.RSPACK_DEV_SERVER_BASE_PORT !== 'undefined'
337339
? Number.parseInt(process.env.RSPACK_DEV_SERVER_BASE_PORT, 10)
@@ -1457,7 +1459,7 @@ class Server<
14571459

14581460
this.setupWatchFiles();
14591461
this.setupWatchStaticFiles();
1460-
this.setupMiddlewares();
1462+
await this.setupMiddlewares();
14611463

14621464
if (this.options.setupExitSignals) {
14631465
const signals = ['SIGINT', 'SIGTERM'];
@@ -1577,7 +1579,7 @@ class Server<
15771579
}
15781580
}
15791581

1580-
setupMiddlewares(): void {
1582+
async setupMiddlewares(): Promise<void> {
15811583
let middlewares: Middleware[] = [];
15821584

15831585
// Register setup host header check for security
@@ -1644,7 +1646,9 @@ class Server<
16441646

16451647
// compress is placed last and uses unshift so that it will be the first middleware used
16461648
if (this.options.compress) {
1647-
const compression = require('compression');
1649+
const { default: compression } = await import(
1650+
/* webpackChunkName: "compression" */ 'compression'
1651+
);
16481652
middlewares.push({ name: 'compression', middleware: compression() });
16491653
}
16501654

0 commit comments

Comments
 (0)