function createRoutesReloader(server, routes) {
	routes.addEventListener("reload", handleRoutesReload);
	return () => routes.removeEventListener("reload", handleRoutesReload);
	function handleRoutesReload() {
		const { moduleGraph } = server;
		const mod = moduleGraph.getModuleById(moduleId);
		if (mod) {
			const seen = new Set();
			moduleGraph.invalidateModule(mod, seen);
			server.reloadModule(mod);
		}
		if (!server.config.server.hmr) {
			server.ws.send({ type: "full-reload" });
		}
	}
}
@param {import('vite').ViteDevServer} server
@param {import("../router-modes.js").CompiledRouter} routes