Skip to content

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

Merged
isaacs merged 1 commit into
developfrom
isaacschlueter/split-server-browser-core-exports
May 9, 2026
Merged

feat(core): split exports by browser/server for bundle size#20435
isaacs merged 1 commit into
developfrom
isaacschlueter/split-server-browser-core-exports

Conversation

@isaacs

@isaacsisaacs commented Apr 21, 2026

Copy link
Copy Markdown
Member

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

@linear-code

Copy link
Copy Markdown

@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch 6 times, most recently from 143a2a5 to 1494709CompareApril 22, 2026 01:45
@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser26.3 kB--
@sentry/browser - with treeshaking flags24.78 kB--
@sentry/browser (incl. Tracing)44.17 kB--
@sentry/browser (incl. Tracing + Span Streaming)46.39 kB--
@sentry/browser (incl. Tracing, Profiling)49.14 kB--
@sentry/browser (incl. Tracing, Replay)83.82 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags73.28 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)88.51 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)101.12 kB--
@sentry/browser (incl. Feedback)43.44 kB--
@sentry/browser (incl. sendFeedback)31.11 kB--
@sentry/browser (incl. FeedbackAsync)36.19 kB--
@sentry/browser (incl. Metrics)27.6 kB--
@sentry/browser (incl. Logs)27.73 kB--
@sentry/browser (incl. Metrics & Logs)28.43 kB--
@sentry/react28.04 kB--
@sentry/react (incl. Tracing)46.4 kB--
@sentry/vue31.18 kB--
@sentry/vue (incl. Tracing)46.02 kB--
@sentry/svelte26.32 kB--
CDN Bundle28.9 kB-0.01%-2 B 🔽
CDN Bundle (incl. Tracing)46.94 kB--
CDN Bundle (incl. Logs, Metrics)30.33 kB-0.01%-3 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics)48.03 kB-0.01%-4 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics)69.64 kB-0.01%-4 B 🔽
CDN Bundle (incl. Tracing, Replay)84.32 kB+0.01%+3 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)85.4 kB+0.01%+1 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback)90.12 kB-0.01%-6 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)91.22 kB+0.03%+27 B 🔺
CDN Bundle - uncompressed84.88 kB--
CDN Bundle (incl. Tracing) - uncompressed140.44 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed89.08 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed143.9 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed213.9 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed259.14 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed262.59 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed272.84 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed276.28 kB--
@sentry/nextjs (client)48.9 kB--
@sentry/sveltekit (client)44.64 kB--
@sentry/node-core60.48 kB+0.02%+7 B 🔺
@sentry/node165.51 kB+0.01%+9 B 🔺
@sentry/node - without tracing73.49 kB+0.01%+6 B 🔺
@sentry/aws-serverless107.64 kB+0.01%+5 B 🔺
@sentry/cloudflare (withSentry) - minified169.37 kB--
@sentry/cloudflare (withSentry)427.59 kB--

View base workflow run

@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch 5 times, most recently from d5dddbf to 8eba1e9CompareApril 22, 2026 18:26
@isaacs
isaacs marked this pull request as ready for review April 22, 2026 18:26
Comment threaddev-packages/rollup-utils/utils.mjs Outdated
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 8eba1e9 to 8ea4f5cCompareApril 22, 2026 18:50
Comment threaddev-packages/rollup-utils/npmHelpers.mjs
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 8ea4f5c to 787f44bCompareApril 22, 2026 19:19
@isaacs
isaacs enabled auto-merge (rebase) April 22, 2026 19:19
@isaacs
isaacs disabled auto-merge April 22, 2026 19:19
isaacs added a commit that referenced this pull request Apr 22, 2026
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
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 787f44b to 7076f7cCompareApril 22, 2026 19:20
Comment threadpackages/core/src/shared-exports.ts
Comment threadpackages/core/src/integrations/http/client-subscriptions.ts
@isaacs
isaacs requested review from mydea and timfishApril 23, 2026 14:24
isaacs added a commit that referenced this pull request Apr 23, 2026
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
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 7076f7c to e2cf052CompareApril 23, 2026 14:34
isaacs added a commit that referenced this pull request Apr 23, 2026
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
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from e2cf052 to 67bf5c4CompareApril 23, 2026 14:41
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from c1c9cf0 to 5beb2e3CompareApril 29, 2026 17:22
isaacs added a commit that referenced this pull request Apr 29, 2026
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 more easily
be shared across runtimes.
Some integration requires updating `tsconfig` settings so that tsc knows
it is allowed to look up `package.json` exports. In particular, we
cannot use the `module: "node"` option, or `moduleResolution: "node"`.
In many cases, this means either using `module: "esnext"` and
`moduleResolution: "bundler"`, so that tsc lets the bundler handle the
assembly, or `nodenext` or `node16` for both `module` and
`moduleResolution`.
fix: #20434
fix: JS-2243
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 5beb2e3 to ca38b53CompareApril 29, 2026 20:43
Comment threaddev-packages/rollup-utils/utils.mjs Outdated
isaacs added a commit that referenced this pull request Apr 29, 2026
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 more easily
be shared across runtimes.
Some integration requires updating `tsconfig` settings so that tsc knows
it is allowed to look up `package.json` exports. In particular, we
cannot use the `module: "node"` option, or `moduleResolution: "node"`.
In many cases, this means either using `module: "esnext"` and
`moduleResolution: "bundler"`, so that tsc lets the bundler handle the
assembly, or `nodenext` or `node16` for both `module` and
`moduleResolution`.
fix: #20434
fix: JS-2243
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from ca38b53 to 24304feCompareApril 29, 2026 20:52

@cursorcursorBot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 24304fe. Configure here.

Comment threadpackages/solidstart/test/server/errorboundary.test.tsx Outdated
isaacs added a commit that referenced this pull request Apr 29, 2026
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 more easily
be shared across runtimes.
Some integration requires updating `tsconfig` settings so that tsc knows
it is allowed to look up `package.json` exports. In particular, we
cannot use the `module: "node"` option, or `moduleResolution: "node"`.
In many cases, this means either using `module: "esnext"` and
`moduleResolution: "bundler"`, so that tsc lets the bundler handle the
assembly, or `nodenext` or `node16` for both `module` and
`moduleResolution`.
fix: #20434
fix: JS-2243
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 24304fe to da8cd5aCompareApril 29, 2026 21:07
isaacs added a commit that referenced this pull request Apr 29, 2026
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 more easily
be shared across runtimes.
Some integration requires updating `tsconfig` settings so that tsc knows
it is allowed to look up `package.json` exports. In particular, we
cannot use the `module: "node"` option, or `moduleResolution: "node"`.
In many cases, this means either using `module: "esnext"` and
`moduleResolution: "bundler"`, so that tsc lets the bundler handle the
assembly, or `nodenext` or `node16` for both `module` and
`moduleResolution`.
fix: #20434
fix: JS-2243
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from da8cd5a to 8fe31cbCompareApril 29, 2026 21:19
isaacs added a commit that referenced this pull request Apr 30, 2026
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 more easily
be shared across runtimes.
Some integration requires updating `tsconfig` settings so that tsc knows
it is allowed to look up `package.json` exports. In particular, we
cannot use the `module: "node"` option, or `moduleResolution: "node"`.
In many cases, this means either using `module: "esnext"` and
`moduleResolution: "bundler"`, so that tsc lets the bundler handle the
assembly, or `nodenext` or `node16` for both `module` and
`moduleResolution`.
fix: #20434
fix: JS-2243
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 8fe31cb to 28b47ecCompareApril 30, 2026 00:05
Comment threadpackages/core/src/server-exports.ts
isaacs added a commit that referenced this pull request Apr 30, 2026
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 more easily
be shared across runtimes.
Some integration requires updating `tsconfig` settings so that tsc knows
it is allowed to look up `package.json` exports. In particular, we
cannot use the `module: "node"` option, or `moduleResolution: "node"`.
In many cases, this means either using `module: "esnext"` and
`moduleResolution: "bundler"`, so that tsc lets the bundler handle the
assembly, or `nodenext` or `node16` for both `module` and
`moduleResolution`.
fix: #20434
fix: JS-2243
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 28b47ec to a783c2eCompareApril 30, 2026 00:25

@JPeer264JPeer264 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.

Do you think it would make sense to add size limit / bundle checks for these exports?

Comment threadpackages/browser/test/tracing/setActiveSpan.test.ts
isaacs added a commit that referenced this pull request May 4, 2026
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 more easily
be shared across runtimes.
Some integration requires updating `tsconfig` settings so that tsc knows
it is allowed to look up `package.json` exports. In particular, we
cannot use the `module: "node"` option, or `moduleResolution: "node"`.
In many cases, this means either using `module: "esnext"` and
`moduleResolution: "bundler"`, so that tsc lets the bundler handle the
assembly, or `nodenext` or `node16` for both `module` and
`moduleResolution`.
fix: #20434
fix: JS-2243
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from a783c2e to 6494082CompareMay 4, 2026 16:27

@JPeer264JPeer264 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.

Changes LGTM, also it is backwards compatible so we can ship it 🚢

The question is still valid: #20435 (review)

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 more easily
be shared across runtimes.
Some integration requires updating `tsconfig` settings so that tsc knows
it is allowed to look up `package.json` exports. In particular, we
cannot use the `module: "node"` option, or `moduleResolution: "node"`.
In many cases, this means either using `module: "esnext"` and
`moduleResolution: "bundler"`, so that tsc lets the bundler handle the
assembly, or `nodenext` or `node16` for both `module` and
`moduleResolution`.
fix: #20434
fix: JS-2243
@isaacs
isaacsforce-pushed the isaacschlueter/split-server-browser-core-exports branch from 6494082 to 5e89a33CompareMay 9, 2026 22:22
@isaacs
isaacs enabled auto-merge (squash) May 9, 2026 22:54
@isaacs
isaacs merged commit 80f05ff into developMay 9, 2026
513 of 515 checks passed
@isaacs
isaacs deleted the isaacschlueter/split-server-browser-core-exports branch May 9, 2026 23:06
@isaacs

Copy link
Copy Markdown
MemberAuthor

@JPeer264

Sorry, thought I replied to this, but I guess gh mobile ate it:

Do you think it would make sense to add size limit / bundle checks for these exports?

Yes, 100%. I intend to do this on a subsequent PR.

JPeer264 pushed a commit that referenced this pull request May 12, 2026
## Summary
- Adds `browser.d.ts` and `server.d.ts` to the `files` list in
`@sentry/core` `package.json` so they are included in the published npm
tarball
- Adds `typesVersions` entries for `browser` and `server` subpaths to
support TypeScript < 5.0
## Context
PR [#20435](#20435)
introduced `@sentry/core/browser` and `@sentry/core/server` subpath
exports and added root-level `.d.ts` shim files for compatibility with
TypeScript compilers that don't support the `exports` field (e.g.
`moduleResolution: "node"`). However, the `.d.ts` shims were not added
to the `files` list, so they were excluded from the published `10.53.0`
tarball.
This breaks downstream consumers like `@sentry/react-native`
([getsentry/sentry-react-native#6139](getsentry/sentry-react-native#6139))
— their TS compiler can't resolve `@sentry/core/browser`, causing
`BaseTransportOptions` to become unresolvable and
`ReactNativeTransportOptions` to fail the type constraint check:
```
error TS2344: Type 'ReactNativeTransportOptions' does not satisfy the constraint 'BaseTransportOptions'.
Type 'ReactNativeTransportOptions' is missing the following properties from type 'BaseTransportOptions': url, recordDroppedEvent
```
## Test plan
- [ ] Verify `npm pack --dry-run` includes `browser.d.ts` and
`server.d.ts` at the package root
- [ ] Verify `@sentry/react-native` builds successfully against a
patched `@sentry/core`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

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

4 participants

@isaacs@timfish@mydea@JPeer264