Patroclazzo
Patroclazzo
DTDrizzle Team
Created by nightspite on 10/11/2023 in #help
exclude models from bundle
Hi, still me. Not sure that is necessary tho. If you have a zod schema that describe the return and input schema of the api call you should get a type error there without this "demonic things". The db structure could differ from the api contract in the future, keep in mid that.
15 replies
DTDrizzle Team
Created by nightspite on 10/11/2023 in #help
exclude models from bundle
PS. I encourage you to try Nx to manage your monorepo. It has a lot more features than turborepo with a nicer (my opinion) dx.
15 replies
DTDrizzle Team
Created by nightspite on 10/11/2023 in #help
exclude models from bundle
Let me know if what I wrote make sense 🙂
15 replies
DTDrizzle Team
Created by nightspite on 10/11/2023 in #help
exclude models from bundle
Our team does not use drizzle-zod package for this reason. The contract between the server and the client is ensured by an series of isomorphic libs that enforce the schema that are separated from the table definition (first solution). It's more verbose, but you don't have to worry about bundle size and bundling issues like this. Another solution could be using something like https://trpc.io/ instead of ts-rest. The fact that you are only exporting the type and not an actual object (meaning the zod validation object) make the import disappears when transpilled in actual js code, so you do not have this problem. (of course you loose the consistency check at runtime on the frontend, but still the dx you are looking for is there)
15 replies
DTDrizzle Team
Created by nightspite on 10/11/2023 in #help
exclude models from bundle
The issue here is the fact that you need the drizzle shemas to generate the validation zod objects to be used in ts-rest. There is no excaping that, you need part of the drizzle library code to be present in the frontend bundle. You can exclude the db driver module since you are not going to connect to a database from the frontend; but other than that I see no solution to this problem. Ts-rest in their examples write the router (with the relative zod schemas) separated (in a specific file or specific lib) form the db and server side stuff (meaning db schema definition), so that code is isomorphic and can run both on the client and on the server. This is an architectural problem, it needs an architectural solution.
15 replies