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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@
"@types/serve-static": "^2.2.0",
"@types/ws": "^8.18.1",
"chokidar": "^3.6.0",
"compression": "^1.8.1",
"connect-history-api-fallback": "^2.0.0",
"express": "^5.2.1",
"http-proxy-middleware": "^3.0.5",
"ipaddr.js": "^2.3.0",
"p-retry": "^7.1.1",
"serve-index": "^1.9.2",
"webpack-dev-middleware": "^7.4.5",
"ws": "^8.19.0"
Expand All @@ -74,6 +72,7 @@
"@types/node-forge": "^1.3.14",
"@types/trusted-types": "^2.0.7",
"@types/ws": "8.18.1",
"compression": "^1.8.1",
"connect": "^3.7.0",
"cross-env": "^10.1.0",
"css-loader": "^7.1.4",
Expand All @@ -82,6 +81,7 @@
"launch-editor": "^2.13.1",
"nano-staged": "^0.9.0",
"open": "^11.0.0",
"p-retry": "^7.1.1",
"prettier": "3.8.1",
"puppeteer": "^24.37.5",
"react-refresh": "0.18.0",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

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

14 changes: 9 additions & 5 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as path from 'node:path';
import * as url from 'node:url';
import * as util from 'node:util';
import ipaddr from 'ipaddr.js';
import { getPort } from './getPort';
import { WebsocketServer } from './servers/WebsocketServer';
import type {
AddressInfo,
Expand Down Expand Up @@ -330,8 +331,9 @@ class Server<
return port;
}

const { default: pRetry } = await import('p-retry');
const { getPort } = await import('./getPort');
const { default: pRetry } = await import(
/* webpackChunkName: "p-retry" */ 'p-retry'
);
const basePort =
typeof process.env.RSPACK_DEV_SERVER_BASE_PORT !== 'undefined'
? Number.parseInt(process.env.RSPACK_DEV_SERVER_BASE_PORT, 10)
Expand Down Expand Up @@ -1457,7 +1459,7 @@ class Server<

this.setupWatchFiles();
this.setupWatchStaticFiles();
this.setupMiddlewares();
await this.setupMiddlewares();

if (this.options.setupExitSignals) {
const signals = ['SIGINT', 'SIGTERM'];
Expand Down Expand Up @@ -1577,7 +1579,7 @@ class Server<
}
}

setupMiddlewares(): void {
async setupMiddlewares(): Promise<void> {
let middlewares: Middleware[] = [];

// Register setup host header check for security
Expand Down Expand Up @@ -1644,7 +1646,9 @@ class Server<

// compress is placed last and uses unshift so that it will be the first middleware used
if (this.options.compress) {
const compression = require('compression');
const { default: compression } = await import(
/* webpackChunkName: "compression" */ 'compression'
);
middlewares.push({ name: 'compression', middleware: compression() });
}

Expand Down