From 0d70686bcc0229fcb5ca55ad11de024524a70cfa Mon Sep 17 00:00:00 2001 From: OrJDev Date: Thu, 2 Mar 2023 15:10:23 +0200 Subject: [PATCH] Fix: prpc vite / packages --- .changeset/modern-foxes-drum.md | 5 +++++ src/helpers/packages.ts | 2 +- src/helpers/vite.ts | 17 +++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 .changeset/modern-foxes-drum.md diff --git a/.changeset/modern-foxes-drum.md b/.changeset/modern-foxes-drum.md new file mode 100644 index 0000000..7f85bb5 --- /dev/null +++ b/.changeset/modern-foxes-drum.md @@ -0,0 +1,5 @@ +--- +"create-jd-app": patch +--- + +Fix: prpc vite / packages diff --git a/src/helpers/packages.ts b/src/helpers/packages.ts index 26e747c..e492ba4 100644 --- a/src/helpers/packages.ts +++ b/src/helpers/packages.ts @@ -15,7 +15,7 @@ const packages = { // prisma "@prisma/client": "^4.10.1", // prpc - "@prpc/solid": "^0.2.0", + "@prpc/solid": "^0.2.1", "@adeora/solid-query": "^0.20.0", // trpc "@tanstack/solid-query": "^5.0.0-alpha.0", diff --git a/src/helpers/vite.ts b/src/helpers/vite.ts index 7ba24d3..f709077 100644 --- a/src/helpers/vite.ts +++ b/src/helpers/vite.ts @@ -5,6 +5,8 @@ import type { ICtx, IUtil } from "~types"; export const getViteConfig: IUtil = (ctx) => { const useUno = ctx.installers.includes("UnoCSS"); const usePrisma = ctx.installers.includes("Prisma"); + const usePrpc = ctx.installers.includes("pRPC"); + const withPrpc = usePrpc ? "prpc(), " : ""; const getPlugins = () => { if (useUno && ctx.vercel) { return `[ @@ -12,11 +14,11 @@ export const getViteConfig: IUtil = (ctx) => { UnoCSS(), ]`; } else if (useUno) { - return `[solid({ ssr: ${ctx.ssr} }), UnoCSS()]`; + return `[${withPrpc}solid({ ssr: ${ctx.ssr} }), UnoCSS()]`; } else if (ctx.vercel) { - return `[solid({ ssr: ${ctx.ssr}, adapter: vercel({ edge: false }) })]`; + return `[${withPrpc}solid({ ssr: ${ctx.ssr}, adapter: vercel({ edge: false }) })]`; } else { - return `[solid({ ssr: ${ctx.ssr} })]`; + return `[${withPrpc}solid({ ssr: ${ctx.ssr} })]`; } }; const plugins = getPlugins(); @@ -24,10 +26,8 @@ export const getViteConfig: IUtil = (ctx) => { useUno ? `\nimport UnoCSS from "unocss/vite";` : "" } import { defineConfig } from "vite";${ - ctx.vercel - ? `\nimport vercel from "solid-start-vercel";` - : "" - } + ctx.vercel ? `\nimport vercel from "solid-start-vercel";` : "" + }${usePrpc ? `\nimport prpc from "@prpc/solid";` : ""} export default defineConfig(() => { return { @@ -44,7 +44,8 @@ export const modifyConfigIfNeeded = async (ctx: ICtx) => { ctx.vercel || ctx.installers.includes("UnoCSS") || !ctx.ssr || - ctx.installers.includes("Prisma") + ctx.installers.includes("Prisma") || + ctx.installers.includes("pRPC") ) { await fs.writeFile( path.join(ctx.userDir, "vite.config.ts"),