Skip to content

Drop @opentelemetry/api from peerDependencies - #6116

Open
candrewlee14 wants to merge 1 commit into
drizzle-team:mainfrom
candrewlee14:drop-otel-peer
Open

Drop @opentelemetry/api from peerDependencies#6116
candrewlee14 wants to merge 1 commit into
drizzle-team:mainfrom
candrewlee14:drop-otel-peer

Conversation

@candrewlee14

Copy link
Copy Markdown

Small one, from #6115.

Why

@opentelemetry/api is only used for types in src/tracing.ts, and the runtime import is commented out:

import type { Span, Tracer } from '@opentelemetry/api';
let otel: typeof import('@opentelemetry/api') | undefined;
// try {
// 	otel = await import('@opentelemetry/api');
// } catch (err: any) { ... }

So otel is never assigned and startActiveSpan always takes the if (!otel) return fn() path. tracer is @internal and isn't exported from the public entry, so published 1.0.0-rc.1 has no runtime or .d.ts reference to it.

It's already in devDependencies, so types still resolve when you build.

What it fixes

Listing it as an optional peer makes package managers that install a separate copy per peer combination give each consumer its own copy of drizzle-orm. TypeScript then treats those copies as unrelated, so values like SQL stop being assignable between packages in a workspace. In ours that was one of the causes of ~50 type errors.

This drops one cause of that and costs nothing here.

Scope

Four deleted lines in drizzle-orm/package.json. No code changes. If you'd rather keep the peer entry for documentation, feel free to close — the other suggestions in #6115 are the larger part.

It is a type-only import in src/tracing.ts, and the runtime import is
commented out, so `otel` is never assigned and startActiveSpan always
takes the `if (!otel) return fn()` path. `tracer` is marked @internal
and is not exported from the public entry, so published 1.0.0-rc.1 has no
runtime or .d.ts reference to @opentelemetry/api.

It is already in devDependencies, so types still resolve when building.

Declaring it as an optional peer makes package managers that specialise
per peer set install a separate copy of drizzle-orm for each consumer
that has a different mix of optional peers installed. TypeScript then
treats those copies as unrelated types, so values like SQL stop being
assignable between packages. Removing the peer entry drops one cause of
that at no cost here.

@hknakn hknakn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified against main: the @opentelemetry/api import in src/tracing.ts is type-only with the runtime await import commented out, nothing else under drizzle-orm/src references it, and it's already in devDependencies at the same ^1.4.1. No-op at runtime and for published types.

We're hit by the wider issue in #6115 — the expo-sqlite entry puts 76 Expo/RN packages into our Node images. Opened #6219 for that one.

This looks safe to merge on its own.

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.

2 participants