From 990d6703c3d7bdcd8596e38d4e91a0d956475358 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Wed, 29 Nov 2023 23:33:22 +0530 Subject: [PATCH 1/2] remove classic runtime for react --- boilerplates/react/files/$vite.config.ts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boilerplates/react/files/$vite.config.ts.ts b/boilerplates/react/files/$vite.config.ts.ts index 9358c8974..4c6b8c066 100644 --- a/boilerplates/react/files/$vite.config.ts.ts +++ b/boilerplates/react/files/$vite.config.ts.ts @@ -13,7 +13,7 @@ export default async function getViteConfig(props: TransformerProps) { from: "@vitejs/plugin-react", constructor: "react", // see https://github.com/vitejs/vite/discussions/5803#discussioncomment-5562200 - options: { jsxRuntime: "classic" }, + options: {}, }); addVitePlugin(mod, { from: "vike/plugin", From 7d3425bd60ac35843300332cf75897eeb2de5ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Charles?= Date: Thu, 30 Nov 2023 11:27:07 +0100 Subject: [PATCH 2/2] fix: only activate jsxRuntime: "classic" for a specific combination --- boilerplates/react/files/$vite.config.ts.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/boilerplates/react/files/$vite.config.ts.ts b/boilerplates/react/files/$vite.config.ts.ts index 4c6b8c066..7857cb194 100644 --- a/boilerplates/react/files/$vite.config.ts.ts +++ b/boilerplates/react/files/$vite.config.ts.ts @@ -3,22 +3,23 @@ import { addVitePlugin, loadAsMagicast, type TransformerProps } from "@batijs/co export default async function getViteConfig(props: TransformerProps) { const mod = await loadAsMagicast(props); - const options = props.meta.BATI.has("vercel") + const vikeOptions = props.meta.BATI.has("vercel") ? { prerender: true, } : {}; + // See https://github.com/batijs/bati/pull/124 + const reactOptions = props.meta.BATI.has("vercel") && props.meta.BATI.has("hattip") ? { jsxRuntime: "classic" } : {}; addVitePlugin(mod, { from: "@vitejs/plugin-react", constructor: "react", - // see https://github.com/vitejs/vite/discussions/5803#discussioncomment-5562200 - options: {}, + options: reactOptions, }); addVitePlugin(mod, { from: "vike/plugin", constructor: "ssr", - options, + options: vikeOptions, }); return mod.generate().code;