create-t3-turbo icon indicating copy to clipboard operation
create-t3-turbo copied to clipboard

Enable Prisma Client caching by Turbo and hoist Client artifacts

Open ernestoresende opened this issue 2 years ago • 1 comments

This PR addresses the error warn(prisma-client) There are already 10 instances of Prisma Client actively running when adding Prisma to Next.js, as recommeded by Prisma on https://www.prisma.io/docs/guides/database/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices.

Additionally, I've been able to restore turbo caching to the generate-db script from packages/db and hoist the generated artifacts from the client to the root of the project. This seems to solve the problem found with Next, where it doesn't play well with non-node_module dirs.

To reproduce and test caching behavior for the Prisma Client and applications:

  1. Clone the repo and install the dependencies.
  2. Run the build script on the root of the project. It should both generate the client, and build the @acme/nextjs project.
  3. Run the build script a second time. It should be a full Turbo cache of both the Prisma client and the Next.js application.
  4. Modify something on @acme/nextjs to invalidate it's cache. Run the build script again. The Prisma Client should be pulled from cache, while the application is rebuilt.
  5. Modify something on the Prisma schema file. Run the build script again. Both the Prisma Client and the application should get rebuilt.

I can't say for sure how well these settings are going to play with Turbo's Remote caching, and my current environment also doesn't let me experiment with the Expo project very well.

ernestoresende avatar Oct 20 '22 21:10 ernestoresende

@ernestoresende is attempting to deploy a commit to the t3-oss Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 20 '22 21:10 vercel[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
create-t3-turbo ✅ Ready (Inspect) Visit Preview Oct 21, 2022 at 9:18AM (UTC)

vercel[bot] avatar Oct 21 '22 07:10 vercel[bot]