close
Skip to content

feat(core): split exports by browser/server for bundle size#20435

Draft
isaacs wants to merge 4 commits intodevelopfrom
isaacschlueter/split-server-browser-core-exports
Draft

feat(core): split exports by browser/server for bundle size#20435
isaacs wants to merge 4 commits intodevelopfrom
isaacschlueter/split-server-browser-core-exports

Conversation

@isaacs
Copy link
Copy Markdown
Member

@isaacs isaacs commented Apr 21, 2026

Note: stacked atop #20393, only the top commit needs review. Land that before this one.

Split the exports from @sentry/core into three options:

  • @sentry/core, the default (unchanged)
  • @sentry/core/browser, containing only shared and browser-specific
    functionality, nothing server-specific.
  • @sentry/core/server, containing only shared and server-specific
    functionality, nothing browser-specific.

This allows us to make the bundle sizes quite a bit smaller in our
browser SDKs where this is important, while adding more functionality to
our server-specific SDKs, in @sentry/core where they can be easily
shared across runtimes.

fix: #20434
fix: JS-2243

isaacs added 3 commits April 21, 2026 09:19
This was implemented for the portable Express integration, but others
will need the same functionality, so make it a reusable util.
Refactor the `node:http` outgoing request instrumentation so that it can
be applied to non-Node.js environments by patching the http module.

Also, refactor so that the diagnostics_channel and monkeypatching paths
can share code, and so that light and normal node-core instrumentations
can share more of the functionality as well.

To facilitate this, some portable minimal types are vendored in from the
`node:http` module.
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 21, 2026

@isaacs isaacs force-pushed the isaacschlueter/split-server-browser-core-exports branch 6 times, most recently from 143a2a5 to 1494709 Compare April 22, 2026 01:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.88 kB - -
@sentry/browser - with treeshaking flags 24.35 kB - -
@sentry/browser (incl. Tracing) 43.81 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 45.5 kB - -
@sentry/browser (incl. Tracing, Profiling) 48.73 kB - -
@sentry/browser (incl. Tracing, Replay) 82.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.5 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 87.67 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 99.93 kB - -
@sentry/browser (incl. Feedback) 42.7 kB - -
@sentry/browser (incl. sendFeedback) 30.55 kB - -
@sentry/browser (incl. FeedbackAsync) 35.55 kB - -
@sentry/browser (incl. Metrics) 27.16 kB - -
@sentry/browser (incl. Logs) 27.29 kB - -
@sentry/browser (incl. Metrics & Logs) 27.98 kB - -
@sentry/react 27.62 kB - -
@sentry/react (incl. Tracing) 46.05 kB - -
@sentry/vue 30.71 kB - -
@sentry/vue (incl. Tracing) 45.62 kB - -
@sentry/svelte 25.89 kB - -
CDN Bundle 28.58 kB +0.04% +9 B 🔺
CDN Bundle (incl. Tracing) 46.08 kB +0.01% +2 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.95 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 47.11 kB -0.02% -5 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 68.92 kB -0.01% -3 B 🔽
CDN Bundle (incl. Tracing, Replay) 83.14 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 84.17 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 88.62 kB +0.02% +11 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 89.69 kB -0.01% -1 B 🔽
CDN Bundle - uncompressed 83.59 kB - -
CDN Bundle (incl. Tracing) - uncompressed 137.62 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 87.73 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 141.03 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 211.31 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 255.06 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 258.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 267.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 271.36 kB - -
@sentry/nextjs (client) 48.58 kB - -
@sentry/sveltekit (client) 44.22 kB - -
@sentry/node-core 58.69 kB +1.17% +675 B 🔺
@sentry/node 167.22 kB -4.39% -7.67 kB 🔽
@sentry/node - without tracing 93.77 kB -4.29% -4.2 kB 🔽
@sentry/aws-serverless 107.71 kB -6.5% -7.48 kB 🔽

View base workflow run

@isaacs isaacs force-pushed the isaacschlueter/split-server-browser-core-exports branch from 3a6735d to 5b7c0f3 Compare April 22, 2026 03:38
Split the exports from `@sentry/core` into three options:

- `@sentry/core`, the default (unchanged)
- `@sentry/core/browser`, containing _only_ shared and browser-specific
  functionality, nothing server-specific.
- `@sentry/core/server`, containing _only_ shared and server-specific
  functionality, nothing browser-specific.

This should allow us to make the bundle sizes quite a bit smaller in our
browser SDKs where this is important, while adding more functionality to
our server-specific SDKs, in `@sentry/core` where they can be easily
shared across runtimes.

Integration may require updating our `tsconfig` settings so that tsc
knows it is allowed to look on `package.json` exports.

fix: #20434
fix: JS-2243
@isaacs isaacs force-pushed the isaacschlueter/split-server-browser-core-exports branch from c251e9c to 4ba6e09 Compare April 22, 2026 05:14
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.

Split @sentry/core exports up, adding ./server and ./browser exports

1 participant