Skip to content

Commit

Permalink
ref: use new @sentry-internal/integration-shims package
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Mar 13, 2023
1 parent 69e9d19 commit a16ebe8
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"packages/hub",
"packages/integration-tests",
"packages/integrations",
"packages/integration-shims",
"packages/overhead-metrics",
"packages/nextjs",
"packages/node",
Expand Down
1 change: 1 addition & 0 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"tslib": "^1.9.3"
},
"devDependencies": {
"@sentry-internal/integration-shims": "7.42.0",
"@types/md5": "2.1.33",
"btoa": "^1.2.1",
"chai": "^4.1.2",
Expand Down
8 changes: 8 additions & 0 deletions packages/integration-shims/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Note: All paths are relative to the directory in which eslint is being run, rather than the directory where this file
// lives

// ESLint config docs: https://eslint.org/docs/user-guide/configuring/

module.exports = {
extends: ['../../.eslintrc.js'],
};
14 changes: 14 additions & 0 deletions packages/integration-shims/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2023 Sentry (https://sentry.io) and individual contributors. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 9 additions & 0 deletions packages/integration-shims/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<p align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
</a>
</p>

# Sentry Integration Shims

This internal package exports shims for Integrations, which are used in order to guarantee a consistent CDN bundle output.
44 changes: 44 additions & 0 deletions packages/integration-shims/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@sentry-internal/integration-shims",
"version": "7.42.0",
"description": "Shims for integrations in Sentry SDK.",
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"sideEffects": false,
"private": true,
"scripts": {
"build": "run-p build:transpile build:types",
"build:transpile": "rollup -c rollup.npm.config.js",
"build:types": "tsc -p tsconfig.types.json",
"build:dev": "yarn build",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "run-p build:watch",
"build:transpile:watch": "yarn build:rollup --watch",
"build:types:watch": "yarn build:types --watch",
"clean": "rimraf build",
"fix": "run-s fix:eslint fix:prettier",
"fix:eslint": "eslint . --format stylish --fix",
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
"lint": "run-s lint:prettier lint:eslint",
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/getsentry/sentry-javascript.git"
},
"author": "Sentry",
"license": "MIT",
"bugs": {
"url": "https://github.com/getsentry/sentry-javascript/issues"
},
"devDependencies": {},
"dependencies": {},
"engines": {
"node": ">=12"
},
"volta": {
"extends": "../../package.json"
}
}
7 changes: 7 additions & 0 deletions packages/integration-shims/rollup.npm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js';

export default makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/index.ts'],
}),
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Integration } from '@sentry/types';
* It is needed in order for the CDN bundles to continue working when users add/remove replay
* from it, without changing their config. This is necessary for the loader mechanism.
*/
export class ReplayShim implements Integration {
class ReplayShim implements Integration {
/**
* @inheritDoc
*/
Expand Down
1 change: 1 addition & 0 deletions packages/integration-shims/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Replay';
11 changes: 11 additions & 0 deletions packages/integration-shims/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "esnext",
"lib": ["ES6"],
"esModuleInterop": true,
"target": "es6",
"strictPropertyInitialization": false
},
"include": ["src/**/*.ts"]
}
10 changes: 10 additions & 0 deletions packages/integration-shims/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"include": ["src/index.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "build/types"
}
}
1 change: 1 addition & 0 deletions packages/tracing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"devDependencies": {
"@sentry/browser": "7.42.0",
"@sentry-internal/integration-shims": "7.42.0",
"@types/express": "^4.17.14"
},
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion rollup/bundleHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function makeBaseBundleConfig(options) {
const licensePlugin = makeLicensePlugin(licenseTitle);
const tsPlugin = makeTSPlugin(jsVersion.toLowerCase());
const excludeReplayPlugin = makeExcludeBlockPlugin('REPLAY');
const excludeReplayShimPlugin = makeExcludeBlockPlugin('REPLAY_SHIM');
const excludeOfflineTransport = makeExcludeBlockPlugin('OFFLINE');
const excludeBrowserProfiling = makeExcludeBlockPlugin('BROWSER_PROFILING');
const replayShimPlugin = makeShimReplayPlugin();
Expand All @@ -65,7 +66,11 @@ export function makeBaseBundleConfig(options) {

if (includeReplay === 'shim') {
standAloneBundleConfig.plugins.push(replayShimPlugin);
} else if (!includeReplay) {
} else {
standAloneBundleConfig.plugins.push(excludeReplayShimPlugin);
}

if (!includeReplay) {
standAloneBundleConfig.plugins.push(excludeReplayPlugin);
}

Expand Down
2 changes: 1 addition & 1 deletion rollup/plugins/bundlePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export function makeShimReplayPlugin() {
// This is designed to replace the re-export in browser/index.ts to export the shim
const plugin = modify({
find: '@sentry/replay',
replace: './shims/Replay',
replace: '@sentry-internal/integration-shims',
});

// give it a nicer name for later, when we'll need to sort the plugins
Expand Down

0 comments on commit a16ebe8

Please sign in to comment.