drizzle-team / drizzle-team/drizzle-orm

37 optional peer deps make pnpm install several copies of drizzle-orm, and TypeScript treats them as different types

Open
#6,115 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What happens

drizzle-orm lists 37 optional peer deps. pnpm installs a separate copy of drizzle-orm for each package that has a different mix of those installed. Same version, different copies.

TypeScript then treats those copies as unrelated, so passing something like a `SQL` value from one of our packages to another fails:

```
Argument of type import(".../drizzle-orm@1.0.0-rc.1_/...").SQL
is not assignable to import(".../drizzle-orm@1.0.0-rc.1_/...").SQL
```

We have 114 packages using drizzle-orm with 14 different mixes, so we end up with 5-7 copies and about 50 type errors. Nothing breaks when the code runs — it's only type checking. pnpm says this is how it's meant to work, so the part that can change is the peer list.

### Two easy fixes

**1. Drop `@opentelemetry/api`.** In published 1.0.0-rc.1 nothing references it — not one runtime file, not one type file. It splits copies for no reason.

**2. Drop the optional peer entries.** For an optional peer they only give you a version warning. Anyone importing `drizzle-orm/mysql2` already installs `mysql2` themselves. Removing the entries stops the extra copies and needs no code changes.

If you want to go further: the `zod`, `valibot`, `typebox`, `arktype` and `effect-schema` folders don't use anything from the rest of drizzle-orm (28 files each, nothing outside them imports them), and `drizzle-zod`, `drizzle-valibot` and `drizzle-typebox` already exist as their own packages for 0.x.

### Notes

1.0.0-rc.1 and 1.0.0-rc.3 have the same peer list, so this isn't specific to a version. Related but different: #3990, #5573, #5825, and pnpm#8163 (that one is about two different versions, not two copies of one version).

Contributor guide

Open the contributing guide

Research direction

Start by reviewing drizzle-orm's peer dependency declarations and the optional schema adapter folders named in the issue. Reproduce the install with pnpm and run TypeScript checks across the affected packages. Done means unnecessary peer entries no longer create duplicate drizzle-orm copies or the reported cross-package type errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.