runDevServer function
Runs a development server for a Routed app.
Note:
- This does not implement hot reloading yet; it simply spawns the target entrypoint with vm-service enabled, which is required for hot reload.
- A future revision can wire in
hotreloaderand file watchers, using DevOptions.watch to fine-tune reload scopes.
Implementation
Future<Process> runDevServer(DevOptions options, {CliLogger? logger}) async {
final log = logger ?? CliLogger(verbose: options.verbose);
// Arguments to enable the Dart VM service (hot reload capability).
final args = <String>[
'--enable-vm-service',
options.entry,
'--host',
options.host,
'--port',
'${options.port}',
];
log.debug('Spawning: dart ${args.join(' ')}');
final env = <String, String>{
// Expose a version string to the child process (useful for diagnostics).
CliVersion.envKey: await CliVersion.resolve(),
};
final process = await spawnDartProcess(args, environment: env);
log.info('Development server started (pid=${process.pid})');
return process;
}