Skip to content

Commit ca7f90b

Browse files
authored
fix: proxy type error (#3936)
1 parent 841f862 commit ca7f90b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/core/prebundle.config.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ export default {
116116
)}`,
117117
);
118118
},
119+
afterBundle(task) {
120+
replaceFileContent(
121+
join(task.distPath, 'index.d.ts'),
122+
(content) =>
123+
// TODO: Due to the breaking change of http-proxy-middleware, it needs to be upgraded in rsbuild 2.0
124+
// https://github.com/chimurai/http-proxy-middleware/pull/730
125+
`${content
126+
.replace('express.Request', 'http.IncomingMessage')
127+
.replace('express.Response', 'http.ServerResponse')
128+
.replace(
129+
'extends express.RequestHandler {',
130+
`{
131+
(req: Request, res: Response, next?: (err?: any) => void): void | Promise<void>;`,
132+
)}`,
133+
);
134+
},
119135
},
120136
{
121137
// The webpack-bundle-analyzer version was locked to v4.9.0 to be compatible with Rspack

0 commit comments

Comments
 (0)