UNPKG

hydro-js-integrations

Version:
41 lines (39 loc) 1.3 kB
import type { getRenderer } from "../server.js"; import hydroJSVite from "../vite.js"; import type { AstroIntegration } from "astro"; export default function hydroJS({ renderer, }: { renderer?: ReturnType<typeof getRenderer> } = {}): AstroIntegration { return { name: "astro-hydro-js", hooks: { "astro:config:setup": async ({ addRenderer, updateConfig }) => { addRenderer({ name: "hydro-js", clientEntrypoint: "hydro-js-integrations/astro/client.js", serverEntrypoint: "hydro-js-integrations/astro/server.js", }); updateConfig({ vite: { plugins: [hydroJSVite({ renderer })], }, }); }, "astro:config:done": ({ logger, config }) => { const knownJsxRenderers = [ "@astrojs/react", "@astrojs/preact", "@astrojs/solid-js", ]; const enabledKnownJsxRenderers = config.integrations.filter( (renderer) => knownJsxRenderers.includes(renderer.name) ); if (enabledKnownJsxRenderers.length > 1) { logger.warn( "More than one JSX renderer is enabled. This will lead to unexpected behavior for now." ); } }, }, }; }