Commit d99cacd
ref(core)!: Split browser/server-only exports out of the default entrypoint (#23762)
Splits the browser- and server-only exports out of `@sentry/core`'s
default entrypoint. `@sentry/core` now exposes **only isomorphic code**,
and the `@sentry/core/browser` and `@sentry/core/server` entrypoints now
contain **only** their platform-specific exports instead of also
re-exporting the shared surface on top.
Previously the default entrypoint re-exported everything (via
`shared-exports.ts`), and both `/browser` and `/server` re-exported that
shared surface plus their platform extras. That meant importing anything
from `@sentry/core` could drag server-only code (http server/client
instrumentation, ANR, postgres/sql helpers, …) into browser bundles, and
the platform entrypoints were never cleanly separable.
After this change:
- **`@sentry/core`** — isomorphic exports only (the former
`shared-exports.ts`, inlined into `index.ts`).
- **`@sentry/core/browser`** — browser-only exports, e.g. the guarded
`startSpan`/`startInactiveSpan` variants that install
`spanStreamingIntegration`.
- **`@sentry/core/server`** — server-only exports:
`ServerRuntimeClient`, `ServerRuntimeOptions`, `trpcMiddleware`,
`wrapMcpServerWithSentry`, the http client/server subscription APIs,
`flushIfServerless`, `loadModule`, node stack-trace helpers,
postgres/sql instrumentation, and more.
Consumer packages were updated to import platform-specific symbols from
the matching entrypoint rather than from `@sentry/core`.
_Root cause_ of the guarded-span split: the browser SDK's `init()`
deliberately omits `spanStreamingIntegration` — referencing it would
keep the whole span-streaming graph in every bundle, including
error-only ones. Because the plain and guarded span-start APIs share
their names, importing the plain variant in browser code compiles fine
but produces spans that are then never sent. The new
`no-unguarded-span-apis` lint rule is the only thing that catches this,
and enforces that browser-facing code imports the span-start APIs from
`@sentry/core/browser`.
### Decisions
- The three entrypoints are kept **disjoint** rather than having
`/browser` and `/server` re-export the isomorphic surface. Consumers
import isomorphic code from `@sentry/core` and platform code from the
matching subpath — this is what makes the separation meaningful for
tree-shaking and bundle size.
- Marked breaking (`!`): symbols previously reachable from
`@sentry/core` (e.g. `trpcMiddleware`, `wrapMcpServerWithSentry`) now
live under `@sentry/core/server`.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 26108fe commit d99cacd
226 files changed
Lines changed: 1113 additions & 1138 deletions
File tree
- dev-packages
- deno-integration-tests/suites/direct-client-acs
- e2e-tests/test-applications
- nuxt-3/server/plugins
- tsx-express/src
- node-integration-tests/suites/tracing
- postgres-streamed
- postgresjs-streamed
- postgresjs
- postgres
- packages
- astro/src/server
- browser-utils/src
- performance
- browser
- src
- integrations-bundle
- integrations
- featureFlags
- growthbook
- launchdarkly
- openfeature
- statsig
- unleash
- pluggable-exports-bundle
- profiling
- tracing
- transports
- utils
- test
- helper
- integrations
- featureFlags/growthbook
- mocks
- profiling
- tracekit
- tracing
- transports
- bundler-plugins/src/core/sentry
- bun/src
- integrations
- cloudflare/src
- instrumentations
- worker
- vendor
- core
- src
- test
- lib
- integrations
- utils
- deno
- src
- integrations
- test
- effect/src
- eslint-plugin-sdk/src/rules
- feedback/src/core
- integration-shims/src
- nextjs
- src
- common/utils
- config
- test
- common/utils
- config
- webpack
- nitro
- src/runtime/hooks
- test/runtime/hooks
- node-native/src
- node
- src
- integrations
- anr
- http
- sdk
- test/integrations
- nuxt
- src/runtime
- hooks
- utils
- test/runtime/hooks
- react-router
- src/server
- test/server
- react
- src
- reactrouter-compat-utils
- test
- remix
- src
- client
- cloudflare
- server
- test/server
- replay-internal/src
- coreHandlers
- util
- server-utils/src/integrations
- mysql2
- solidstart
- src/server
- test/server
- sveltekit/src/server-common
- tanstackstart-react
- src/server
- test/server
- vercel-edge/src
- vue/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
0 commit comments