|
1 | 1 | import type { Server } from 'node:http'; |
2 | 2 | import type { Http2SecureServer } from 'node:http2'; |
3 | | -import { color } from '../helpers'; |
| 3 | +import { color, pick } from '../helpers'; |
4 | 4 | import { getPublicPathFromCompiler, isMultiCompiler } from '../helpers/compiler'; |
5 | 5 | import { requestRestart, watchFilesForRestart } from '../restart'; |
6 | 6 | import type { |
@@ -85,8 +85,13 @@ export async function createDevServer< |
85 | 85 | options: Options, |
86 | 86 | createCompiler: CreateCompiler, |
87 | 87 | config: NormalizedConfig, |
88 | | - { getPortSilently, runCompile = true }: CreateDevServerOptions = {}, |
| 88 | + devServerOptions: CreateDevServerOptions = {}, |
89 | 89 | ): Promise<RsbuildDevServer> { |
| 90 | + const { getPortSilently, runCompile = true } = devServerOptions; |
| 91 | + const restartContext = { |
| 92 | + action: 'dev' as const, |
| 93 | + options: pick(devServerOptions, ['getPortSilently']), |
| 94 | + }; |
90 | 95 | const { context } = options; |
91 | 96 | const { logger } = context; |
92 | 97 | logger.debug('create dev server'); |
@@ -228,7 +233,7 @@ export async function createDevServer< |
228 | 233 | // Request a manual restart and close the old watcher only after it succeeds. |
229 | 234 | const restartServer = async () => { |
230 | 235 | const restarted = await requestRestart({ |
231 | | - action: 'dev', |
| 236 | + restartContext, |
232 | 237 | clear: false, |
233 | 238 | logger, |
234 | 239 | restartManager: context.restartManager, |
@@ -455,7 +460,7 @@ export async function createDevServer< |
455 | 460 | state.restartWatcher = watchFilesForRestart({ |
456 | 461 | watchFiles: config.dev.watchFiles, |
457 | 462 | context, |
458 | | - action: 'dev', |
| 463 | + restartContext, |
459 | 464 | }); |
460 | 465 |
|
461 | 466 | logger.debug('create dev server done'); |
|
0 commit comments