Skip to content

Commit 20272b7

Browse files
committed
build(replay): Provide full browser+tracing+replay bundle
1 parent aed2ce6 commit 20272b7

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

.size-limit.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,10 @@ module.exports = [
7878
limit: '48 KB',
7979
ignore: ['@sentry/browser', '@sentry/utils', '@sentry/core', '@sentry/types'],
8080
},
81+
{
82+
name: '@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified)',
83+
path: 'packages/tracing/build/bundles/bundle.tracing.replay.min.js',
84+
gzip: true,
85+
limit: '100 KB',
86+
},
8187
];

packages/tracing/rollup.bundle.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,16 @@ const builds = [];
1414
builds.push(...makeBundleConfigVariants(baseBundleConfig));
1515
});
1616

17+
// Full bundle incl. replay only avaialable for es6
18+
const baseBundleConfig = makeBaseBundleConfig({
19+
bundleType: 'standalone',
20+
entrypoints: ['src/index.bundle.ts'],
21+
jsVersion: 'es6',
22+
licenseTitle: '@sentry/tracing & @sentry/browser & @sentry/replay',
23+
outputFileBase: () => 'bundles/bundle.tracing.replay',
24+
includeReplay: true,
25+
});
26+
27+
builds.push(...makeBundleConfigVariants(baseBundleConfig));
28+
1729
export default builds;

packages/tracing/src/index.bundle.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,12 @@ export { BrowserTracing };
8484
addExtensionMethods();
8585

8686
export { addExtensionMethods };
87+
88+
// DO NOT DELETE THESE COMMENTS!
89+
// We want to exclude Replay from CDN bundles, so we remove the block below with our
90+
// excludeReplay Rollup plugin when generating bundles. Everything between
91+
// ROLLUP_EXCLUDE_FROM_BUNDLES_BEGIN and _END__ is removed for bundles.
92+
93+
// __ROLLUP_EXCLUDE_FROM_BUNDLES_BEGIN__
94+
export { Replay } from '@sentry/browser';
95+
// __ROLLUP_EXCLUDE_FROM_BUNDLES_END__

rollup/bundleHelpers.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import { mergePlugins } from './utils';
2323
const BUNDLE_VARIANTS = ['.js', '.min.js', '.debug.min.js'];
2424

2525
export function makeBaseBundleConfig(options) {
26-
const { bundleType, entrypoints, jsVersion, licenseTitle, outputFileBase, packageSpecificConfig } = options;
26+
const { bundleType, entrypoints, jsVersion, licenseTitle, outputFileBase, packageSpecificConfig, includeReplay } =
27+
options;
2728

2829
const nodeResolvePlugin = makeNodeResolvePlugin();
2930
const sucrasePlugin = makeSucrasePlugin();
@@ -45,9 +46,13 @@ export function makeBaseBundleConfig(options) {
4546
name: 'Sentry',
4647
},
4748
context: 'window',
48-
plugins: [markAsBrowserBuildPlugin, excludeReplayPlugin],
49+
plugins: [markAsBrowserBuildPlugin],
4950
};
5051

52+
if (!includeReplay) {
53+
standAloneBundleConfig.plugins.push(excludeReplayPlugin);
54+
}
55+
5156
// used by `@sentry/integrations` and `@sentry/wasm` (bundles which need to be combined with a stand-alone SDK bundle)
5257
const addOnBundleConfig = {
5358
// These output settings are designed to mimic an IIFE. We don't use Rollup's `iife` format because we don't want to

0 commit comments

Comments
 (0)