Skip to content

Commit d99cacd

Browse files
mydeaclaude
andauthored
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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎dev-packages/deno-integration-tests/suites/direct-client-acs/scenario.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
// (it waits for the tracing-channel binding), so a nested db span here proves
88
// `DenoClient.init()` installs that strategy on the direct-construction path.
99
// Without it, the subscriber never binds and no span is produced.
10-
import { createStackParser, nodeStackLineParser } from '@sentry/core';
10+
import { createStackParser } from '@sentry/core';
11+
import { nodeStackLineParser } from '@sentry/core/server';
1112
import { DenoClient, getCurrentScope, getDefaultIntegrations, startSpan } from '@sentry/deno';
1213
import { tracingChannel } from 'node:diagnostics_channel';
1314

‎dev-packages/e2e-tests/test-applications/nuxt-3/server/plugins/customNitroErrorHandler.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Context, flushIfServerless } from '@sentry/core';
1+
import { Context } from '@sentry/core';
2+
import { flushIfServerless } from '@sentry/core/server';
23
import * as SentryNode from '@sentry/node';
34
import { H3Error } from 'h3';
45
import type { CapturedErrorContext } from 'nitropack';

‎dev-packages/e2e-tests/test-applications/tsx-express/src/mcp.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mc
44
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
55
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
66
import { z } from 'zod';
7-
import { wrapMcpServerWithSentry } from '@sentry/core';
7+
import { wrapMcpServerWithSentry } from '@sentry/node';
88

99
// Helper to check if request is an initialize request (compatible with all MCP SDK versions)
1010
function isInitializeRequest(body: unknown): boolean {

‎dev-packages/node-integration-tests/suites/tracing/postgres-streamed/scenario-native.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Sentry from '@sentry/node';
2-
import { uuid4 } from '@sentry/core/server';
2+
import { uuid4 } from '@sentry/core';
33
import { waitForConnection } from '@sentry-internal/node-integration-tests';
44
import pg from 'pg';
55

‎dev-packages/node-integration-tests/suites/tracing/postgres-streamed/scenario.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Sentry from '@sentry/node';
2-
import { uuid4 } from '@sentry/core/server';
2+
import { uuid4 } from '@sentry/core';
33
import { waitForConnection } from '@sentry-internal/node-integration-tests';
44
import { Client } from 'pg';
55

‎dev-packages/node-integration-tests/suites/tracing/postgres/scenario-native.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Sentry from '@sentry/node';
2-
import { uuid4 } from '@sentry/core/server';
2+
import { uuid4 } from '@sentry/core';
33
import { waitForConnection } from '@sentry-internal/node-integration-tests';
44
import pg from 'pg';
55

‎dev-packages/node-integration-tests/suites/tracing/postgres/scenario.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Sentry from '@sentry/node';
2-
import { uuid4 } from '@sentry/core/server';
2+
import { uuid4 } from '@sentry/core';
33
import { waitForConnection } from '@sentry-internal/node-integration-tests';
44
import { Client } from 'pg';
55

‎dev-packages/node-integration-tests/suites/tracing/postgresjs-streamed/scenario-requestHook.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Sentry from '@sentry/node';
2-
import { uuid4 } from '@sentry/core/server';
2+
import { uuid4 } from '@sentry/core';
33
import postgres from 'postgres';
44
import { waitForConnection } from '@sentry-internal/node-integration-tests';
55

‎dev-packages/node-integration-tests/suites/tracing/postgresjs-streamed/scenario-unsafe.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Sentry from '@sentry/node';
2-
import { uuid4 } from '@sentry/core/server';
2+
import { uuid4 } from '@sentry/core';
33
import postgres from 'postgres';
44
import { waitForConnection } from '@sentry-internal/node-integration-tests';
55

‎dev-packages/node-integration-tests/suites/tracing/postgresjs-streamed/scenario-url.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Sentry from '@sentry/node';
2-
import { uuid4 } from '@sentry/core/server';
2+
import { uuid4 } from '@sentry/core';
33
import postgres from 'postgres';
44
import { waitForConnection } from '@sentry-internal/node-integration-tests';
55

0 commit comments

Comments
 (0)