You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using trpc in bunch of projects that are spread across npm packages. E.g., I have a server my-server and a client my-client. In my-client code I am importing AppRouter like this:
importtype{AppRouter}from`my-server`;
I want to be able to publish AppRouter types on NPM without exposing any sensitive information like my server source code or Context of the AppRouter.
Describe the solution you'd like to see
When generating .d.ts files via tsc or vite, .d.ts files contain all imported type definitions. Since AppRouter depends on Context, and Context usually contains all backend services (e.g., UsersService, PaymentService, etc), all the backend type declarations are also included in .d.ts files.
I see at least two solutions:
Somehow replace Context object with unknown when generating .d.ts files
If appRouter is defined in src/router.ts, only include dist/router.d.ts in package.json files field.
I hope trpc provides a recommended way to publish AppRouter, so developers do not need to think about it themselves.
Describe alternate solutions
Don't provide a recommended way of publishing AppRouter and leave it to devs.
Additional information
No response
👨👧👦 Contributing
🙋♂️ Yes, I'd be down to file a PR implementing this feature!
Funding
You can sponsor this specific effort via a Polar.sh pledge below
We receive the pledge once the issue is completed & verified
The text was updated successfully, but these errors were encountered:
According to the description of the linked PR, context object is still included in the router type(although context is no longer present in procedure types). Is it possible to remove context from .d.ts altogether?
The rest could technically be omitted with regards to the client.
However, in order to call router.createCaller() we'd need the Context.... potentially we could have a way to strip out stuff from routers that'd still work to create clients from.
Feel free to hack on this, know it's quite time consuming though, but you have pretty free reign to challenge how we do things seeing that it's a major change upcoming anyway
Describe the feature you'd like to request
I am using trpc in bunch of projects that are spread across npm packages. E.g., I have a server
my-server
and a clientmy-client
. Inmy-client
code I am importingAppRouter
like this:I want to be able to publish
AppRouter
types on NPM without exposing any sensitive information like my server source code orContext
of theAppRouter
.Describe the solution you'd like to see
When generating .d.ts files via
tsc
orvite
, .d.ts files contain all imported type definitions. SinceAppRouter
depends onContext
, andContext
usually contains all backend services (e.g.,UsersService
,PaymentService
, etc), all the backend type declarations are also included in .d.ts files.I see at least two solutions:
Context
object withunknown
when generating .d.ts filesappRouter
is defined insrc/router.ts
, only includedist/router.d.ts
in package.jsonfiles
field.I hope trpc provides a recommended way to publish
AppRouter
, so developers do not need to think about it themselves.Describe alternate solutions
Don't provide a recommended way of publishing
AppRouter
and leave it to devs.Additional information
No response
👨👧👦 Contributing
Funding
The text was updated successfully, but these errors were encountered: