function handlerBuild() {
	return {
		name: "react-rsc:handler",
		async config({ router, app }, env) {
			if (env.command === "build") {
				invariant(
					router && router.type !== "static" && router.handler,
					"Invalid router",
				);
				const { builtinModules } = await import("module");
				const { join } = await import("./path.js");
				const input = await getEntries(router);
				let base = join(app?.config.server.baseURL ?? "/", router.base);
				return {
					build: {
						rollupOptions: {
							input,
							external: [
								...builtinModules,
								...builtinModules.map((m) => `node:${m}`),
							],
							treeshake: true,
							preserveEntrySignatures: "exports-only",
						},
						ssr: true,
						cssMinify: "esbuild",
						minify: process.env.MINIFY !== "false" ?? true,
						manifest: true,
						target: "node18",
						ssrEmitAssets: true,
						outDir: join(router.outDir, router.base),
						emptyOutDir: false,
					},
					base,
					publicDir: false,
				};
			}
		},
	};
}
@returns {import('./vite-dev.d.ts').Plugin}