Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore (client): add Zod and Prisma as (optional) peer dependencies #1187

Merged
merged 3 commits into from Apr 30, 2024

Conversation

kevin-dp
Copy link
Contributor

Every Electric app needs Zod in order to use the generated client. However, in recent versions of Zod something changed that breaks the types in the generated client (cf. #700). Therefore, Electric apps should always use Zod version 3.21.1. Added this as a peer dependency such that npm complains if the app installs a different version. Similarly, added an optional peer dependency for Prisma v4 such that it complains if the app installs another version of Prisma.

Copy link
Contributor

@samwillis samwillis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pin Prisma, but not Zod. There are valid reasons to use a different version of Zod, one being that at the moment the pinned version of Zod does not handle UUIDv7. So it's up to the user to decide if they want to trade type errors for UUIDv7 (and other UUID format) support.

@kevin-dp
Copy link
Contributor Author

We can pin Prisma, but not Zod. There are valid reasons to use a different version of Zod, one being that at the moment the pinned version of Zod does not handle UUIDv7. So it's up to the user to decide if they want to trade type errors for UUIDv7 (and other UUID format) support.

@samwillis I think most projects will want to use the version of Zod required by Electric, and only a small number of projects will want to use another version of Zod, e.g. for UUIDv7 support. Therefore, i like pinning Zod as this informs developpers automatically if they have a wrong version of Zod in their project. For the occasional case where one really needs another version of Zod, they can use npm install --force to force their version of Zod, right?

Copy link
Contributor

@samwillis samwillis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevin-dp agreed, lest merge this and revisit in future.

@msfstef
Copy link
Contributor

msfstef commented Apr 29, 2024

Looks good and agree with adding them as peerDeps - although I'm pretty sure Prisma also needs to be exactly 4.8.1 because I remember trying to update it to the latest v4 version when I looked at the generation and there were already issues with minor version updates.

I've also opened a PR to add some other missing optional flags for existing peer deps which are causing issues in projects:
#1205

msfstef added a commit that referenced this pull request Apr 29, 2024
Adds peer dependency optional flags that are missing (also reordered to
match peer dep order).

Relevant PR: #1187
@kevin-dp kevin-dp merged commit 0115a0a into main Apr 30, 2024
8 checks passed
@kevin-dp kevin-dp deleted the kevindp/package-deps branch April 30, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants