Skip to content

Commit 7265349

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

File tree

6 files changed

+40
-11
lines changed

6 files changed

+40
-11
lines changed

.size-limit.js

+6
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/replay/README.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,7 @@ You have to add it in addition to the Sentry Browser SDK bundle:
9898
```js
9999
// Browser SDK bundle
100100
<script
101-
src="https://browser.sentry-cdn.com/7.24.1/bundle.tracing.min.js"
102-
crossorigin="anonymous"
103-
></script>
104-
105-
// Replay integration bundle
106-
<script
107-
src="https://browser.sentry-cdn.com/7.24.1/replay.min.js"
101+
src="https://browser.sentry-cdn.com/7.31.0/bundle.tracing.replay.min.js"
108102
crossorigin="anonymous"
109103
></script>
110104

packages/tracing/rollup.bundle.config.js

+12
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 replayBaseBundleConfig = 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(replayBaseBundleConfig));
28+
1729
export default builds;

packages/tracing/src/index.bundle.ts

+9
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

+7-2
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

rollup/plugins/bundlePlugins.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,14 @@ export function makeTSPlugin(jsVersion) {
173173
*/
174174
export function makeExcludeReplayPlugin() {
175175
const replacementRegex = /\/\/ __ROLLUP_EXCLUDE_FROM_BUNDLES_BEGIN__(.|\n)*__ROLLUP_EXCLUDE_FROM_BUNDLES_END__/m;
176-
const browserIndexFilePath = path.resolve(__dirname, '../../packages/browser/src/index.ts');
176+
const filePathsToMatch = [
177+
path.resolve(__dirname, '../../packages/browser/src/index.ts'),
178+
path.resolve(__dirname, '../../packages/tracing/src/index.bundle.ts'),
179+
];
177180

178181
const plugin = {
179182
transform(code, id) {
180-
const isBrowserIndexFile = path.resolve(id) === browserIndexFilePath;
183+
const isBrowserIndexFile = filePathsToMatch.includes(path.resolve(id));
181184
if (!isBrowserIndexFile || !replacementRegex.test(code)) {
182185
return null;
183186
}

0 commit comments

Comments
 (0)