berry
berry copied to clipboard
[Bug?]: pnpm linker: yarn 4 upgrade breaks `yarn prisma generate`
Self-service
- [X] I'd be willing to implement a fix
Describe the bug
Example reproduction: https://github.com/dawnmist/prisma-generate-repro Initial upstream issue created: https://github.com/prisma/prisma/issues/22534
Prisma is a typescript ORM that generates typescript table access/types/definition files from a human-readable schema definition file. These files are compiled into a package that gets stored in node_modules.
In yarn 3.7.0, the files generated from the schema are co-located inside the @prisma-client-virtual package (containing @prisma/client and .prisma/client). The .prisma/client files are generated when the @prisma/client package is rebuilt. Running yarn prisma generate in yarn 3 results in this @prisma/client package being rebuilt, so the .prisma/client files are updated to match the schema.
In yarn 4.0.x, the files generated end up in a separate package .prisma/client inside node_modules/.store instead of being co-located in the @prisma-client-virtual package. Running yarn prisma generate does not result in the @prisma/client package being recompiled, which means that the files in the .prisma/client package are not being regenerated to match schema changes properly. In order to regenerate those files, manually running yarn rebuild @prisma/client is required to trigger the rebuild that used to occur automatically.
What is needed to ensure that yarn prisma generate triggers a rebuild of the @prisma/client package under yarn 4? Is this something that prisma can fix (and if so, how?), or is this something needing to be addressed on the yarn side?
To reproduce
- Clone the repository https://github.com/dawnmist/prisma-generate-repro and cd into the repo directory
yarn install- check the
StripeCustomerWhereUniqueInputtype innode_modules/.prisma/client/index.d.ts, and note that it requires at least one ofidoruserEmail. - edit the
schema.prismafile, and add an annotation@uniqueto the end of theStripeCustomer=>emailfield - run
yarn prisma generate - check the
StripeCustomerWhereUniqueInputtype innode_modules/.prisma/client/index.d.ts, and note that it still only requires at least one ofidoruserEmail- theemailfield should have been added as a result of adding the@uniquetag, but wasn't because the@prisma/clientpackage didn't get rebuilt. - run
yarn rebuild @prisma/client - check the
StripeCustomerWhereUniqueInputtype innode_modules/.prisma/client/index.d.ts, and note that it now after rebuilding properly requires one ofidoruserEmailoremail.
Environment
System:
OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (32) x64 AMD Ryzen 9 3950X 16-Core Processor
Binaries:
Node: 20.10.0 - /tmp/xfs-5068250d/node
Yarn: 4.0.2 - /tmp/xfs-5068250d/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
Additional context
Yarn 3 node_modules layout:
Yarn 4 node_modules layout:
Can you please confirm if this issue is still active ? I am trying to generate prisma client for yarn 4 and I can't find a workaround.