Skip to content

Conversation

mmkal
Copy link
Owner

@mmkal mmkal commented Jun 11, 2025

CC @unnoq

I didn't end up using orpc's json-schema converter - trpc-cli is already doing the conversion to json-schema, presumably a similar way, but I borrowed the use of resolveContractProcedures from there.

One concern I have is the fact that resolveContractProcedures returns Promise<void> - I'm calling it from a sync context and would rather not make everything async. It seems to work anyway though, is that expected?

@unnoq
Copy link

unnoq commented Jun 11, 2025

Because oRPC support lazy routers so resolveContractProcedures return a promise is expected.

If you don't care about lazy router, you can use traverseContractProcedures and don't care about return

Copy link

pkg-pr-new bot commented Jun 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/mmkal/trpc-cli@105

commit: d633214

@mmkal
Copy link
Owner Author

mmkal commented Jun 11, 2025

Because oRPC support lazy routers so resolveContractProcedures return a promise is expected.

If you don't care about lazy router, you can use traverseContractProcedures and don't care about return

Perfect, much nicer - thanks @unnoq! Damn you really thought of everything. As I was writing it I was thinking "there should be a method just like this one but that synchronously returns the lazy router paths" and then exactly that exists. Has happened many times with orpc.

@mmkal mmkal marked this pull request as ready for review June 11, 2025 16:45
@mmkal mmkal merged commit 11350cb into main Jun 11, 2025
7 checks passed
@mmkal mmkal deleted the orpc branch June 11, 2025 17:08
Copy link
Contributor

This is included in v0.9.0.

@jlucaso1
Copy link

Hey @mmkal. It's possible to put the trpc/server dep as a development dependency?
I'm thinking in the following scenario: If I, as a user, want to use only orpc I necessarily need to have trpc installed?

@mmkal
Copy link
Owner Author

mmkal commented Jun 11, 2025

I go back and forth on this. The reason it's a prod dependency is to make it possible to write a CLI just by installing this library on its own. With trpc based CLIs this wasn't a big deal since you'd likely end up with only one version in node_modules even if you have your own separate trpc/server.

But with orpc, yes, there will be an unnecessary trpc/server in your/your users' node_modules.

Having said that it's a pretty lightweight, has no dependencies itself, and (I'm assuming) only used on servers (node/bun/deno) anyway? Is the concern just install size?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants