mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
feat(cli): optimize oRPC client dependencies by removing server dependency (#515)
Co-authored-by: Aman Varshney <amanvarshney.work@gmail.com>
This commit is contained in:
5
.changeset/bright-areas-film.md
Normal file
5
.changeset/bright-areas-film.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-better-t-stack": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
optimize oRPC client dependencies by removing server dependency
|
||||||
@@ -54,11 +54,7 @@ export async function setupApi(config: ProjectConfig) {
|
|||||||
if (hasReactWeb) {
|
if (hasReactWeb) {
|
||||||
if (api === "orpc") {
|
if (api === "orpc") {
|
||||||
await addPackageDependency({
|
await addPackageDependency({
|
||||||
dependencies: [
|
dependencies: ["@orpc/tanstack-query", "@orpc/client"],
|
||||||
"@orpc/tanstack-query",
|
|
||||||
"@orpc/client",
|
|
||||||
"@orpc/server",
|
|
||||||
],
|
|
||||||
projectDir: webDir,
|
projectDir: webDir,
|
||||||
});
|
});
|
||||||
} else if (api === "trpc") {
|
} else if (api === "trpc") {
|
||||||
@@ -79,7 +75,6 @@ export async function setupApi(config: ProjectConfig) {
|
|||||||
"@tanstack/vue-query-devtools",
|
"@tanstack/vue-query-devtools",
|
||||||
"@orpc/tanstack-query",
|
"@orpc/tanstack-query",
|
||||||
"@orpc/client",
|
"@orpc/client",
|
||||||
"@orpc/server",
|
|
||||||
],
|
],
|
||||||
projectDir: webDir,
|
projectDir: webDir,
|
||||||
});
|
});
|
||||||
@@ -90,7 +85,6 @@ export async function setupApi(config: ProjectConfig) {
|
|||||||
dependencies: [
|
dependencies: [
|
||||||
"@orpc/tanstack-query",
|
"@orpc/tanstack-query",
|
||||||
"@orpc/client",
|
"@orpc/client",
|
||||||
"@orpc/server",
|
|
||||||
"@tanstack/svelte-query",
|
"@tanstack/svelte-query",
|
||||||
],
|
],
|
||||||
projectDir: webDir,
|
projectDir: webDir,
|
||||||
@@ -102,7 +96,6 @@ export async function setupApi(config: ProjectConfig) {
|
|||||||
dependencies: [
|
dependencies: [
|
||||||
"@orpc/tanstack-query",
|
"@orpc/tanstack-query",
|
||||||
"@orpc/client",
|
"@orpc/client",
|
||||||
"@orpc/server",
|
|
||||||
"@tanstack/solid-query",
|
"@tanstack/solid-query",
|
||||||
],
|
],
|
||||||
projectDir: webDir,
|
projectDir: webDir,
|
||||||
@@ -123,11 +116,7 @@ export async function setupApi(config: ProjectConfig) {
|
|||||||
});
|
});
|
||||||
} else if (api === "orpc") {
|
} else if (api === "orpc") {
|
||||||
await addPackageDependency({
|
await addPackageDependency({
|
||||||
dependencies: [
|
dependencies: ["@orpc/tanstack-query", "@orpc/client"],
|
||||||
"@orpc/tanstack-query",
|
|
||||||
"@orpc/client",
|
|
||||||
"@orpc/server",
|
|
||||||
],
|
|
||||||
projectDir: nativeDir,
|
projectDir: nativeDir,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { createORPCClient } from "@orpc/client";
|
import { createORPCClient } from "@orpc/client";
|
||||||
import { RPCLink } from "@orpc/client/fetch";
|
import { RPCLink } from "@orpc/client/fetch";
|
||||||
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
||||||
import type { RouterClient } from "@orpc/server";
|
|
||||||
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
||||||
import type { appRouter } from "../../server/src/routers";
|
import type { AppRouterClient } from "../../server/src/routers";
|
||||||
{{#if auth}}
|
{{#if auth}}
|
||||||
import { authClient } from "@/lib/auth-client";
|
import { authClient } from "@/lib/auth-client";
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@@ -30,6 +29,6 @@ export const link = new RPCLink({
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
export const client: AppRouterClient = createORPCClient(link);
|
||||||
|
|
||||||
export const orpc = createTanstackQueryUtils(client);
|
export const orpc = createTanstackQueryUtils(client);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { defineNuxtPlugin, useRuntimeConfig } from '#app'
|
import { defineNuxtPlugin, useRuntimeConfig } from '#app'
|
||||||
import type { RouterClient } from '@orpc/server'
|
import type { AppRouterClient } from "../../../server/src/routers/index";
|
||||||
import type { appRouter } from "../../../server/src/routers/index";
|
|
||||||
import { createORPCClient } from '@orpc/client'
|
import { createORPCClient } from '@orpc/client'
|
||||||
import { RPCLink } from '@orpc/client/fetch'
|
import { RPCLink } from '@orpc/client/fetch'
|
||||||
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
||||||
@@ -24,7 +23,7 @@ export default defineNuxtPlugin(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const client: RouterClient<typeof appRouter> = createORPCClient(rpcLink)
|
const client: AppRouterClient = createORPCClient(rpcLink)
|
||||||
const orpcUtils = createTanstackQueryUtils(client)
|
const orpcUtils = createTanstackQueryUtils(client)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import { RPCLink } from "@orpc/client/fetch";
|
|||||||
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
||||||
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import type { appRouter } from "../../../server/src/routers/index";
|
import type { AppRouterClient } from "../../../server/src/routers/index";
|
||||||
import type { RouterClient } from "@orpc/server";
|
|
||||||
|
|
||||||
export const queryClient = new QueryClient({
|
export const queryClient = new QueryClient({
|
||||||
queryCache: new QueryCache({
|
queryCache: new QueryCache({
|
||||||
@@ -37,6 +36,6 @@ export const link = new RPCLink({
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const client: RouterClient<typeof appRouter> = createORPCClient(link)
|
export const client: AppRouterClient = createORPCClient(link)
|
||||||
|
|
||||||
export const orpc = createTanstackQueryUtils(client)
|
export const orpc = createTanstackQueryUtils(client)
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import { createORPCClient } from "@orpc/client";
|
|||||||
import { RPCLink } from "@orpc/client/fetch";
|
import { RPCLink } from "@orpc/client/fetch";
|
||||||
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
||||||
import { QueryCache, QueryClient } from "@tanstack/solid-query";
|
import { QueryCache, QueryClient } from "@tanstack/solid-query";
|
||||||
import type { appRouter } from "../../../server/src/routers/index";
|
import type { AppRouterClient } from "../../../server/src/routers/index";
|
||||||
import type { RouterClient } from "@orpc/server";
|
|
||||||
|
|
||||||
export const queryClient = new QueryClient({
|
export const queryClient = new QueryClient({
|
||||||
queryCache: new QueryCache({
|
queryCache: new QueryCache({
|
||||||
@@ -25,6 +24,6 @@ export const link = new RPCLink({
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
export const client: AppRouterClient = createORPCClient(link);
|
||||||
|
|
||||||
export const orpc = createTanstackQueryUtils(client);
|
export const orpc = createTanstackQueryUtils(client);
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { PUBLIC_SERVER_URL } from "$env/static/public";
|
import { PUBLIC_SERVER_URL } from "$env/static/public";
|
||||||
import { createORPCClient } from "@orpc/client";
|
import { createORPCClient } from "@orpc/client";
|
||||||
import { RPCLink } from "@orpc/client/fetch";
|
import { RPCLink } from "@orpc/client/fetch";
|
||||||
import type { RouterClient } from "@orpc/server";
|
|
||||||
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
||||||
import { QueryCache, QueryClient } from "@tanstack/svelte-query";
|
import { QueryCache, QueryClient } from "@tanstack/svelte-query";
|
||||||
import type { appRouter } from "../../../server/src/routers/index";
|
import type { AppRouterClient } from "../../../server/src/routers/index";
|
||||||
|
|
||||||
export const queryClient = new QueryClient({
|
export const queryClient = new QueryClient({
|
||||||
queryCache: new QueryCache({
|
queryCache: new QueryCache({
|
||||||
@@ -26,6 +25,6 @@ export const link = new RPCLink({
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
export const client: AppRouterClient = createORPCClient(link);
|
||||||
|
|
||||||
export const orpc = createTanstackQueryUtils(client);
|
export const orpc = createTanstackQueryUtils(client);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{{#if (eq api "orpc")}}
|
{{#if (eq api "orpc")}}
|
||||||
import { {{#if auth}}protectedProcedure, {{/if}}publicProcedure } from "../lib/orpc";
|
import { {{#if auth}}protectedProcedure, {{/if}}publicProcedure } from "../lib/orpc";
|
||||||
|
import type { RouterClient } from "@orpc/server";
|
||||||
{{#if (includes examples "todo")}}
|
{{#if (includes examples "todo")}}
|
||||||
import { todoRouter } from "./todo";
|
import { todoRouter } from "./todo";
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@@ -21,6 +22,7 @@ export const appRouter = {
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
};
|
};
|
||||||
export type AppRouter = typeof appRouter;
|
export type AppRouter = typeof appRouter;
|
||||||
|
export type AppRouterClient = RouterClient<typeof appRouter>;
|
||||||
{{else if (eq api "trpc")}}
|
{{else if (eq api "trpc")}}
|
||||||
import {
|
import {
|
||||||
{{#if auth}}protectedProcedure, {{/if}}publicProcedure,
|
{{#if auth}}protectedProcedure, {{/if}}publicProcedure,
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ import { link, orpc } from "@/utils/orpc";
|
|||||||
import type { QueryClient } from "@tanstack/react-query";
|
import type { QueryClient } from "@tanstack/react-query";
|
||||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import type { RouterClient } from "@orpc/server";
|
|
||||||
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
||||||
import type { appRouter } from "../../../server/src/routers";
|
import type { AppRouterClient } from "../../../server/src/routers";
|
||||||
import { createORPCClient } from "@orpc/client";
|
import { createORPCClient } from "@orpc/client";
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (eq api "trpc")}}
|
{{#if (eq api "trpc")}}
|
||||||
@@ -67,7 +66,7 @@ function RootComponent() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
{{#if (eq api "orpc")}}
|
{{#if (eq api "orpc")}}
|
||||||
const [client] = useState<RouterClient<typeof appRouter>>(() => createORPCClient(link));
|
const [client] = useState<AppRouterClient>(() => createORPCClient(link));
|
||||||
const [orpcUtils] = useState(() => createTanstackQueryUtils(client));
|
const [orpcUtils] = useState(() => createTanstackQueryUtils(client));
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user