RPC frontend import
Did anyone else also have the problem of building the frontend app when importing the RPC Types from the backend? How did you solve it? I don't know what to do anymore...
I always get errors on non-existing imports in the frontend - this is pretty easy to understand because they are imports from the backend app. How can I solve it?
5 Replies
sounds like you're using a monorepo, in which case you want to generate a declaration file during transpilation and import the types that way
making imports across a monorepo work also typically requires some configuration, e.g., using workspaces, but that depends on your setup
hard to say more without having a better sense of your project setup
This is basically my project structure
Inside the api package I export from my server app (AppType for the RPC, etc.)
However, when I run in dev mode everything works fine. When building it crashes. Do you need more information @ambergristle ? :) Thanks for helping
Why is /api separate from /server?
Also, how are you generating types, and building the app?
Because I thought that it would solve the problem with the importing
Its just importing and exporting
you should only need to share types from a generated
d.ts
file between web
and server
i would recommend moving api
and ui
back into their respective /app
directories. splitting them out seems like it would just complicate things
if importing/exporting the types also errors, it's probably something to do with your tsconfig or another project config