Skip to content

fix(opentelemetry): Add conditional browser export to avoid node deps - #20556

Merged
mydea merged 3 commits into
developfrom
fn/fix-otel-export
Apr 29, 2026
Merged

fix(opentelemetry): Add conditional browser export to avoid node deps#20556
mydea merged 3 commits into
developfrom
fn/fix-otel-export

Conversation

@mydea

Copy link
Copy Markdown
Member

We accidentally added a node dependency to an export from opentelemetry package, leading to problems for users using this in a browser environment.

This PR adds conditional exports to the opentelemetry package, where for browser targets we have stubs for the node-only thing. This should generally work the same as before, but stop failing builds in browser envs.

I had to adjust browser integration tests for this a bit, as they did some unnecessary aliasing which prevented webpack from using normal conditional exports. We are simply doing less now and doing regular dependency resolution which should work as expected (hopefully).

@mydeamydea self-assigned this Apr 28, 2026
@github-actions

github-actionsBot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser26.16 kB--
@sentry/browser - with treeshaking flags24.63 kB--
@sentry/browser (incl. Tracing)44.11 kB--
@sentry/browser (incl. Tracing + Span Streaming)46.11 kB--
@sentry/browser (incl. Tracing, Profiling)49.06 kB--
@sentry/browser (incl. Tracing, Replay)83.36 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags72.84 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)88.03 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)100.69 kB--
@sentry/browser (incl. Feedback)43.4 kB--
@sentry/browser (incl. sendFeedback)30.96 kB--
@sentry/browser (incl. FeedbackAsync)36.14 kB--
@sentry/browser (incl. Metrics)27.44 kB--
@sentry/browser (incl. Logs)27.59 kB--
@sentry/browser (incl. Metrics & Logs)28.28 kB--
@sentry/react27.9 kB--
@sentry/react (incl. Tracing)46.35 kB--
@sentry/vue31.03 kB--
@sentry/vue (incl. Tracing)45.95 kB--
@sentry/svelte26.18 kB--
CDN Bundle28.84 kB--
CDN Bundle (incl. Tracing)46.65 kB--
CDN Bundle (incl. Logs, Metrics)30.25 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)47.73 kB--
CDN Bundle (incl. Replay, Logs, Metrics)69.25 kB--
CDN Bundle (incl. Tracing, Replay)83.75 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)84.82 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)89.57 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)90.65 kB--
CDN Bundle - uncompressed84.55 kB--
CDN Bundle (incl. Tracing) - uncompressed139.56 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed88.75 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed143.02 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed212.39 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed257.07 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed260.51 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed270.77 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed274.2 kB--
@sentry/nextjs (client)48.84 kB--
@sentry/sveltekit (client)44.56 kB--
@sentry/node-core58.81 kB-0.05%-25 B 🔽
@sentry/node169.14 kB-0.49%-823 B 🔽
@sentry/node - without tracing96.66 kB-1.01%-980 B 🔽
@sentry/aws-serverless113.53 kB-0.72%-822 B 🔽
@sentry/cloudflare (withSentry) - minified163.65 kB--
@sentry/cloudflare (withSentry)414.17 kB--

View base workflow run

@mydea
mydeaforce-pushed the fn/fix-otel-export branch from 4e32f21 to 3924a95CompareApril 28, 2026 09:48
@mydea
mydea requested a review from a teamApril 28, 2026 09:50
@mydea
mydea marked this pull request as ready for review April 28, 2026 12:01
@isaacs
isaacs self-requested a review April 28, 2026 15:01

@isaacsisaacs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Minor possible safety improvement suggestion, but mostly theoretical.

"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"browser": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since we're specifying browser here, it might be safer to put it above node, just to ensure that anything that claims to support this (even if it does so with weird shims etc) can pick up the browser one first.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I wasn't 100% sure about this (and still am not 🤔 ) my thinking for this was that node is def. the main target here, and I want to avoid somebody who has a node target not getting this. IMHO that's more important than somebody who has node & browser targets not getting the node stuff - I'd say it's reasonable that if your targets include node, you get the variant with the node import 😅 but we can always revisit the order if this turns out to be problematic!

@mydea
mydea merged commit a4e888f into developApr 29, 2026
207 of 210 checks passed
@mydea
mydea deleted the fn/fix-otel-export branch April 29, 2026 08:21
Sign up for freeto 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.

3 participants

@mydea@isaacs@andreiborza