diff --git a/packages/tracing/rollup.bundle.config.js b/packages/tracing/rollup.bundle.config.js index 2b9227fd31a9..52aa6396a370 100644 --- a/packages/tracing/rollup.bundle.config.js +++ b/packages/tracing/rollup.bundle.config.js @@ -8,7 +8,7 @@ const builds = []; entrypoints: ['src/index.bundle.ts'], jsVersion, licenseTitle: '@sentry/tracing & @sentry/browser', - includeReplay: 'shim', + includeReplay: false, outputFileBase: () => `bundles/bundle.tracing${jsVersion === 'es5' ? '.es5' : ''}`, }); diff --git a/packages/tracing/src/index.bundle.base.ts b/packages/tracing/src/index.bundle.base.ts new file mode 100644 index 000000000000..a753bab932d4 --- /dev/null +++ b/packages/tracing/src/index.bundle.base.ts @@ -0,0 +1,92 @@ +export type { + Breadcrumb, + Request, + SdkInfo, + Event, + Exception, + // eslint-disable-next-line deprecation/deprecation + Severity, + SeverityLevel, + StackFrame, + Stacktrace, + Thread, + User, +} from '@sentry/types'; + +export type { BrowserOptions, ReportDialogOptions } from '@sentry/browser'; + +export { + addGlobalEventProcessor, + addBreadcrumb, + captureException, + captureEvent, + captureMessage, + configureScope, + getHubFromCarrier, + getCurrentHub, + Hub, + Scope, + setContext, + setExtra, + setExtras, + setTag, + setTags, + setUser, + startTransaction, + makeFetchTransport, + makeXHRTransport, + withScope, +} from '@sentry/browser'; + +export { BrowserClient } from '@sentry/browser'; +export { + defaultIntegrations, + defaultStackParser, + forceLoad, + init, + lastEventId, + onLoad, + showReportDialog, + flush, + close, + wrap, +} from '@sentry/browser'; +export { SDK_VERSION } from '@sentry/browser'; + +import { Integrations as BrowserIntegrations } from '@sentry/browser'; +import type { Integration } from '@sentry/types'; +import { GLOBAL_OBJ } from '@sentry/utils'; + +import { BrowserTracing } from './browser'; +import { addExtensionMethods } from './extensions'; + +export { Span } from '@sentry/core'; + +let windowIntegrations = {}; + +// This block is needed to add compatibility with the integrations packages when used with a CDN +if (GLOBAL_OBJ.Sentry && GLOBAL_OBJ.Sentry.Integrations) { + windowIntegrations = GLOBAL_OBJ.Sentry.Integrations; +} + +// For whatever reason, it does not recognize BrowserTracing or some of the BrowserIntegrations as Integration +const INTEGRATIONS: Record< + string, + Integration | typeof BrowserTracing | typeof BrowserIntegrations[keyof typeof BrowserIntegrations] +> = { + ...windowIntegrations, + ...BrowserIntegrations, + BrowserTracing, +}; + +export { INTEGRATIONS as Integrations }; +// Though in this case exporting `BrowserTracing` separately (in addition to exporting it as part of +// `Sentry.Integrations`) doesn't gain us any bundle size advantage (we're making the bundle here, not the user, and we +// can't leave anything out of ours), it does bring the API for using the integration in line with that recommended for +// users bundling Sentry themselves. +export { BrowserTracing }; + +// We are patching the global object with our hub extension methods +addExtensionMethods(); + +export { addExtensionMethods }; diff --git a/packages/tracing/src/index.bundle.replay.ts b/packages/tracing/src/index.bundle.replay.ts index 403cc6342b65..fe503b961461 100644 --- a/packages/tracing/src/index.bundle.replay.ts +++ b/packages/tracing/src/index.bundle.replay.ts @@ -9,4 +9,4 @@ Sentry.Integrations.Replay = Replay; export { Replay }; -export * from './index.bundle'; +export * from './index.bundle.base'; diff --git a/packages/tracing/src/index.bundle.ts b/packages/tracing/src/index.bundle.ts index b5c27d004c37..ac897b145298 100644 --- a/packages/tracing/src/index.bundle.ts +++ b/packages/tracing/src/index.bundle.ts @@ -1,94 +1,4 @@ -export type { - Breadcrumb, - Request, - SdkInfo, - Event, - Exception, - // eslint-disable-next-line deprecation/deprecation - Severity, - SeverityLevel, - StackFrame, - Stacktrace, - Thread, - User, -} from '@sentry/types'; +// This is exported so the loader does not fail when switching off Replay +export { Replay } from '@sentry-internal/integration-shims'; -export type { BrowserOptions, ReportDialogOptions } from '@sentry/browser'; - -export { - addGlobalEventProcessor, - addBreadcrumb, - captureException, - captureEvent, - captureMessage, - configureScope, - getHubFromCarrier, - getCurrentHub, - Hub, - Scope, - setContext, - setExtra, - setExtras, - setTag, - setTags, - setUser, - startTransaction, - makeFetchTransport, - makeXHRTransport, - withScope, - // This is replaced with a shim in rollup - Replay, -} from '@sentry/browser'; - -export { BrowserClient } from '@sentry/browser'; -export { - defaultIntegrations, - defaultStackParser, - forceLoad, - init, - lastEventId, - onLoad, - showReportDialog, - flush, - close, - wrap, -} from '@sentry/browser'; -export { SDK_VERSION } from '@sentry/browser'; - -import { Integrations as BrowserIntegrations } from '@sentry/browser'; -import type { Integration } from '@sentry/types'; -import { GLOBAL_OBJ } from '@sentry/utils'; - -import { BrowserTracing } from './browser'; -import { addExtensionMethods } from './extensions'; - -export { Span } from '@sentry/core'; - -let windowIntegrations = {}; - -// This block is needed to add compatibility with the integrations packages when used with a CDN -if (GLOBAL_OBJ.Sentry && GLOBAL_OBJ.Sentry.Integrations) { - windowIntegrations = GLOBAL_OBJ.Sentry.Integrations; -} - -// For whatever reason, it does not recognize BrowserTracing or some of the BrowserIntegrations as Integration -const INTEGRATIONS: Record< - string, - Integration | typeof BrowserTracing | typeof BrowserIntegrations[keyof typeof BrowserIntegrations] -> = { - ...windowIntegrations, - ...BrowserIntegrations, - BrowserTracing, -}; - -export { INTEGRATIONS as Integrations }; -// Though in this case exporting `BrowserTracing` separately (in addition to exporting it as part of -// `Sentry.Integrations`) doesn't gain us any bundle size advantage (we're making the bundle here, not the user, and we -// can't leave anything out of ours), it does bring the API for using the integration in line with that recommended for -// users bundling Sentry themselves. -export { BrowserTracing }; - -// We are patching the global object with our hub extension methods -addExtensionMethods(); - -export { addExtensionMethods }; +export * from './index.bundle.base';