Effect CommunityEC
Effect Community7mo ago
2 replies
NotLuksus

Avoid bundling server code with client code in a shared package setup

When I'm using HttpClient on the client side in my react app I get server code bundled, because of codesharing.

Let me explain in more detail:
I have 3 packages relevant here: Api (api definition / groups are stored here)
Auth (all auth logic, including errors, middlewares, etc.)
DB (everything db related)

Auth depends on db, api depends on auth.

Now on the client if I do
yield* HttpApiClient.make(Api, {
                baseUrl: import.meta.env.VITE_SERVER_URL,
                transformClient: (client) =>
                    client.pipe(HttpClient.retryTransient({ times: 3 })),
            }),


The api contains server code aswell.

Is there a way to go the trpc route here and just import type Api, that would resolve that
Was this page helpful?