prisma: Prisma2 packages causes Yarn install devDependencies on --prod

I don’t know which repo should this issue belong to, but apparently, prisma packages causes yarn --prod to install all devDependencies (not npm install --prod=true). Adding either @prisma/photon or nexus-prisma to dependencies cause the wrong yarn behavior, and it is fixed if I moved all prisma packages to devDependencies.

Please have a look into this Yarn issue I created as well. https://github.com/yarnpkg/yarn/issues/7801

Could anyone please explain this problem?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

Next step: verify that this works now

@divyenduz This issue does touch on the package size for a bit but the actual problem is different here which is yarn install all of our packages when we specify nexus-prisma as a dependency and prisma2 a devDependency in production mode. So I think we should keep this open for now.

Yes, same, I already explained why photon is huge right now and we will take actions to fix it but for now maybe stick with npm.

Yes, I can reproduce this. I think this is more related to yarn as npm doesn’t fetch it and we have correctly listed it as a peer dependency in nexus-prisma(which lists @prisma/photon as peerDep) and @prisma/photon(which lists prisma2 as peerDep). I think it has to with how yarn resolves peerDependencies but I am not an expert on dependency resolution. I also tested pnpm and it also doesn’t grab these packages so clear this is very yarn specific: image

Right now as a workaround you can just remove it and use a global install or use it via npx. The size of prisma2 is currently big because we need to ship typescript.

To understand why we ship typescript here is our current generation process:

  1. Call prisma2 generate (either from @prisma/photons postinstall hook or from the user directly)
  2. prisma2 generate now calls the @prisma/photon generator located in @prisma/photon/generator-build/index.js. This generator in memory creates an index.ts file, including the individual Photon build of the project. Now typescript comes in to play: It turns the index.ts file into an index.js and index.d.ts file. We have it on our todo list to directly generate an index.js and index.d.ts file, without the use of TypeScript. That will happen fairly soon / hopefully in Q1. That will make the package size more managable.

We require prisma2 as a peer dep in the first place as @prisma/photon’s hook needs prisma2 to run generate. But as soon as the generation is done, prisma2 is not needed anymore. That means when people have the build done, prisma2 is not needed anymore. So that is why it is not a direct dependency but a peerDependency.