Otherwise you just need to import the
Otherwise you just need to import the generated code (e.g.
useQuery
) from ../../webproject/convex/_generated/react
in the other project9 Replies
is it possible to have "thin" convex presence in these apps for strictly type generation, or is all-or-nothing?
Currently type generation is at the TypeScript level, it actually imports the Convex function modules. So the code does need to be accessible, if not in the same package.json project.
some versions of this are possible today, the really good versions are in the future — when you wouldn't need to have the code locally at all. We'll need to do this for code generation in other languages, but it would also provide this "thin" convex presence.
Ok. Maybe just copying types over is the best approach until I want to bite off the monorepo -- was hoping to avoid that initially.
That makes sense, but copying over types will be a little tough; they aren't reified, the types are just references to the TypeScript implementation files
hmm.. ok.
you could make separate types and then typecheck that they match the Convex implementations, but we're getting off the beaten path here
Maybe I'll try to take a pass with turbo repo... sounds like convex will be both a "package" and an "app" in their world though, so that could get interesting.
I'm also thinking through how this quickly starts to couple with CI and environments (local, dev, staging, prod). I didn't come across any docs around this. Do you have any best practices or examples to review?
oh @sshader points out you could generate could technically throw a
emitDeclarationOnly
in the tsconfig to get real TypeScript types you could copy to other repos or consume as a package
but we don't have any demos of this up, will keep it in mind that this would be useful
By default Convex has development and prod environments, where each user gets their own development environment and the prod is shared
To get additional environments, you'd currently need to create a new project.
signing off to bike to work, but happy to chat about this more later, or other folks will jump inthanks!
I have it working in a turborepo monorepo. The convex app specifies
"main": "convex/_generated/react.js"
in package.json
which can be consumed by the client apps.
To ease development, I added the following to scripts
to the convex app package.json
: "dev": "convex dev"
, so that turborepo starts it along side my other apps in dev mode.