Skip to content

Commit d9716bd

Browse files
committed
feat(core): split exports by browser/server for bundle size
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. Requires updating our `tsconfig` settings so that tsc knows it is allowed to look on `package.json` exports. This then, requires setting some other packages to `"moduleResolution": "bundler"` and `"module": "esnext"` in order to continue working as before. In the case of sveltekit, some types appear to just not be exported in a node16-compatible way, meaning that we now need to read them from the exported function rather than dive into the package contents. fix: #20434 fix: JS-2243
1 parent 8ad3dd0 commit d9716bd

648 files changed

Lines changed: 1845 additions & 1646 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/test-utils/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"compilerOptions": {
44
"target": "ES2022",
55
"module": "ES2022",
6+
"moduleResolution": "bundler",
67
// package-specific options
78
"esModuleInterop": true
89
},

packages/angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@types/node": "^14.8.0",
3939
"ng-packagr": "^14.2.2",
4040
"rxjs": "7.8.2",
41-
"typescript": "4.6.4",
41+
"typescript": "4.8",
4242
"zone.js": "^0.12.0"
4343
},
4444
"scripts": {

packages/angular/src/errorhandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { ErrorHandler as AngularErrorHandler, OnDestroy } from '@angular/co
33
import { Inject, Injectable } from '@angular/core';
44
import type { ReportDialogOptions } from '@sentry/browser';
55
import * as Sentry from '@sentry/browser';
6-
import type { Event } from '@sentry/core';
7-
import { consoleSandbox, isString } from '@sentry/core';
6+
import type { Event } from '@sentry/core/browser';
7+
import { consoleSandbox, isString } from '@sentry/core/browser';
88
import { runOutsideAngular } from './zone';
99

1010
/**

packages/angular/src/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import {
1010
linkedErrorsIntegration,
1111
setContext,
1212
} from '@sentry/browser';
13-
import type { Client, Integration } from '@sentry/core';
13+
import type { Client, Integration } from '@sentry/core/browser';
1414
import {
1515
applySdkMetadata,
1616
conversationIdIntegration,
1717
debug,
1818
dedupeIntegration,
1919
functionToStringIntegration,
2020
inboundFiltersIntegration,
21-
} from '@sentry/core';
21+
} from '@sentry/core/browser';
2222
import { IS_DEBUG_BUILD } from './flags';
2323

2424
/**

packages/angular/src/tracing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
startBrowserTracingNavigationSpan,
2121
startInactiveSpan,
2222
} from '@sentry/browser';
23-
import type { Integration, Span } from '@sentry/core';
24-
import { debug, stripUrlQueryAndFragment, timestampInSeconds } from '@sentry/core';
23+
import type { Integration, Span } from '@sentry/core/browser';
24+
import { debug, stripUrlQueryAndFragment, timestampInSeconds } from '@sentry/core/browser';
2525
import type { Observable } from 'rxjs';
2626
import { Subscription } from 'rxjs';
2727
import { filter, tap } from 'rxjs/operators';

packages/angular/test/errorhandler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { HttpErrorResponse } from '@angular/common/http';
22
import * as SentryBrowser from '@sentry/browser';
3-
import type { Client, Event } from '@sentry/core';
3+
import type { Client, Event } from '@sentry/core/browser';
44
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
55
import { createErrorHandler, SentryErrorHandler } from '../src/errorhandler';
66

packages/angular/test/tracing.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
55
SentrySpan,
66
spanToJSON,
7-
} from '@sentry/core';
7+
} from '@sentry/core/browser';
88
import { describe, it } from 'vitest';
99
import { browserTracingIntegration, init, TraceDirective } from '../src/index';
1010
import { _updateSpanAttributesForParametrizedUrl, getParameterizedRouteFromSnapshot } from '../src/tracing';

packages/angular/vitest.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
// angular has to use an old ts version, so we can't make this as perfectly
2+
// typed as most of our other code, which is why linting is disabled.
3+
// thankfully, it's small enough to not be a problem.
4+
5+
// oxlint-disable
6+
17
import { defineConfig } from 'vitest/config';
8+
//@ts-ignore
29
import baseConfig from '../../vite/vite.config';
310

411
export default defineConfig({

packages/astro/src/client/browserTracingIntegration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import {
33
startBrowserTracingPageLoadSpan,
44
WINDOW,
55
} from '@sentry/browser';
6-
import type { Integration, TransactionSource } from '@sentry/core';
6+
import type { Integration, TransactionSource } from '@sentry/core/browser';
77
import {
88
browserPerformanceTimeOrigin,
99
debug,
1010
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
1111
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
12-
} from '@sentry/core';
12+
} from '@sentry/core/browser';
1313
import { DEBUG_BUILD } from '../debug-build';
1414

1515
/**

packages/astro/src/client/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { BrowserOptions } from '@sentry/browser';
22
import { getDefaultIntegrations as getBrowserDefaultIntegrations, init as initBrowserSdk } from '@sentry/browser';
3-
import type { Client, Integration } from '@sentry/core';
4-
import { applySdkMetadata } from '@sentry/core';
3+
import type { Client, Integration } from '@sentry/core/browser';
4+
import { applySdkMetadata } from '@sentry/core/browser';
55
import { browserTracingIntegration } from './browserTracingIntegration';
66

77
// Tree-shakable guard to remove all code related to tracing

0 commit comments

Comments
 (0)