Skip to content

Commit 4bff5a9

Browse files
authored
feat(bundles): Ensure CDN bundles always have a Replay export (#7414)
1 parent ba99e7c commit 4bff5a9

23 files changed

+367
-92
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"packages/hub",
4848
"packages/integration-tests",
4949
"packages/integrations",
50+
"packages/integration-shims",
5051
"packages/overhead-metrics",
5152
"packages/nextjs",
5253
"packages/node",
@@ -105,6 +106,7 @@
105106
"rollup": "^2.67.1",
106107
"rollup-plugin-cleanup": "3.2.1",
107108
"rollup-plugin-license": "^2.6.1",
109+
"rollup-plugin-modify": "^3.0.0",
108110
"rollup-plugin-terser": "^7.0.2",
109111
"rollup-plugin-typescript2": "^0.31.2",
110112
"sinon": "^7.3.2",

packages/browser/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"tslib": "^1.9.3"
2424
},
2525
"devDependencies": {
26+
"@sentry-internal/integration-shims": "7.43.0",
2627
"@types/md5": "2.1.33",
2728
"btoa": "^1.2.1",
2829
"chai": "^4.1.2",

packages/browser/rollup.bundle.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const builds = [];
88
entrypoints: ['src/index.ts'],
99
jsVersion,
1010
licenseTitle: '@sentry/browser',
11+
includeReplay: 'shim',
1112
outputFileBase: () => `bundles/bundle${jsVersion === 'es5' ? '.es5' : ''}`,
1213
});
1314

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Note: All paths are relative to the directory in which eslint is being run, rather than the directory where this file
2+
// lives
3+
4+
// ESLint config docs: https://eslint.org/docs/user-guide/configuring/
5+
6+
module.exports = {
7+
extends: ['../../.eslintrc.js'],
8+
};

packages/integration-shims/LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright (c) 2023 Sentry (https://sentry.io) and individual contributors. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
5+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
6+
persons to whom the Software is furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
9+
Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/integration-shims/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<p align="center">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4+
</a>
5+
</p>
6+
7+
# Sentry Integration Shims
8+
9+
This internal package exports shims for Integrations, which are used in order to guarantee a consistent CDN bundle output.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@sentry-internal/integration-shims",
3+
"version": "7.43.0",
4+
"description": "Shims for integrations in Sentry SDK.",
5+
"main": "build/cjs/index.js",
6+
"module": "build/esm/index.js",
7+
"types": "build/types/index.d.ts",
8+
"sideEffects": false,
9+
"private": true,
10+
"scripts": {
11+
"build": "run-p build:transpile build:types",
12+
"build:transpile": "rollup -c rollup.npm.config.js",
13+
"build:types": "tsc -p tsconfig.types.json",
14+
"build:dev": "yarn build",
15+
"build:watch": "run-p build:transpile:watch build:types:watch",
16+
"build:dev:watch": "run-p build:watch",
17+
"build:transpile:watch": "yarn build:rollup --watch",
18+
"build:types:watch": "yarn build:types --watch",
19+
"clean": "rimraf build",
20+
"fix": "run-s fix:eslint fix:prettier",
21+
"fix:eslint": "eslint . --format stylish --fix",
22+
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
23+
"lint": "run-s lint:prettier lint:eslint",
24+
"lint:eslint": "eslint . --format stylish",
25+
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\""
26+
},
27+
"repository": {
28+
"type": "git",
29+
"url": "git+https://github.com/getsentry/sentry-javascript.git"
30+
},
31+
"author": "Sentry",
32+
"license": "MIT",
33+
"bugs": {
34+
"url": "https://github.com/getsentry/sentry-javascript/issues"
35+
},
36+
"devDependencies": {},
37+
"dependencies": {
38+
"@sentry/types": "7.43.0"
39+
},
40+
"engines": {
41+
"node": ">=12"
42+
},
43+
"volta": {
44+
"extends": "../../package.json"
45+
}
46+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js';
2+
3+
export default makeNPMConfigVariants(
4+
makeBaseNPMConfig({
5+
entrypoints: ['src/index.ts'],
6+
}),
7+
);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type { Integration } from '@sentry/types';
2+
3+
/**
4+
* This is a shim for the Replay integration.
5+
* It is needed in order for the CDN bundles to continue working when users add/remove replay
6+
* from it, without changing their config. This is necessary for the loader mechanism.
7+
*/
8+
class ReplayShim implements Integration {
9+
/**
10+
* @inheritDoc
11+
*/
12+
public static id: string = 'Replay';
13+
14+
/**
15+
* @inheritDoc
16+
*/
17+
public name: string = ReplayShim.id;
18+
19+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20+
public constructor(_options: any) {
21+
// eslint-disable-next-line no-console
22+
console.error('You are using new Replay() even though this bundle does not include the replay integration.');
23+
}
24+
25+
/** jsdoc */
26+
public setupOnce(): void {
27+
// noop
28+
}
29+
30+
/** jsdoc */
31+
public start(): void {
32+
// noop
33+
}
34+
35+
/** jsdoc */
36+
public stop(): void {
37+
// noop
38+
}
39+
40+
/** jsdoc */
41+
public flush(): void {
42+
// noop
43+
}
44+
}
45+
46+
export { ReplayShim as Replay };
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Replay';

0 commit comments

Comments
 (0)