Skip to content

Commit 77c2dc0

Browse files
committed
build(replay): Provide full browser+tracing+replay bundle
1 parent 38f49ca commit 77c2dc0

File tree

7 files changed

+53
-12
lines changed

7 files changed

+53
-12
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: '80 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

+26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import replace from '@rollup/plugin-replace';
2+
13
import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/index.js';
24

5+
import pkg from './package.json';
6+
37
const builds = [];
48

59
['es5', 'es6'].forEach(jsVersion => {
@@ -14,4 +18,26 @@ const builds = [];
1418
builds.push(...makeBundleConfigVariants(baseBundleConfig));
1519
});
1620

21+
// Full bundle incl. replay only avaialable for es6
22+
const replayBaseBundleConfig = makeBaseBundleConfig({
23+
bundleType: 'standalone',
24+
entrypoints: ['src/index.bundle.replay.ts'],
25+
jsVersion: 'es6',
26+
licenseTitle: '@sentry/tracing & @sentry/browser & @sentry/replay',
27+
outputFileBase: () => 'bundles/bundle.tracing.replay',
28+
includeReplay: true,
29+
packageSpecificConfig: {
30+
plugins: [
31+
replace({
32+
preventAssignment: true,
33+
values: {
34+
__SENTRY_REPLAY_VERSION__: JSON.stringify(pkg.version),
35+
},
36+
}),
37+
],
38+
},
39+
});
40+
41+
builds.push(...makeBundleConfigVariants(replayBaseBundleConfig));
42+
1743
export default builds;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Replay } from '@sentry/browser';
2+
3+
import * as Sentry from './index.bundle';
4+
5+
Sentry.Integrations.Replay = Replay;
6+
7+
export default Sentry;

packages/tracing/src/index.bundle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if (GLOBAL_OBJ.Sentry && GLOBAL_OBJ.Sentry.Integrations) {
6767
windowIntegrations = GLOBAL_OBJ.Sentry.Integrations;
6868
}
6969

70-
const INTEGRATIONS = {
70+
const INTEGRATIONS: Record<string, unknown> = {
7171
...windowIntegrations,
7272
...BrowserIntegrations,
7373
BrowserTracing,

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)