Skip to content

ref(build): Use base rollup config function in @sentry/integrations #4652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 24 additions & 49 deletions packages/integrations/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,44 @@
import * as fs from 'fs';

import { terser } from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';

import {
addOnBundleConfig,
baseBundleConfig,
markAsBrowserBuild,
nodeResolvePlugin,
typescriptPluginES5,
} from '../../rollup.config';

const terserInstance = terser({
mangle: {
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
// as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version.
// We need those full names to correctly detect our internal frames for stripping.
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
properties: {
regex: /^_[^_]/,
},
},
output: {
comments: false,
},
});

const plugins = [
typescriptPluginES5,
// replace `__SENTRY_BROWSER_BUNDLE__` with `true` to enable treeshaking of non-browser code
markAsBrowserBuild,
nodeResolvePlugin,
commonjs(),
];
import { makeBaseBundleConfig, terserPlugin } from '../../rollup.config';

function allIntegrations() {
return fs.readdirSync('./src').filter(file => file != 'index.ts');
}

function loadAllIntegrations() {
const builds = [];
[
{
extension: '.js',
plugins,
},
{
extension: '.min.js',
plugins: [...plugins, terserInstance],
},
].forEach(build => {
builds.push(
...allIntegrations().map(file => ({

allIntegrations().forEach(file => {
const baseBundleConfig = makeBaseBundleConfig({
input: `src/${file}`,
isAddOn: true,
outputFileBase: `build/${file.replace('.ts', '')}`,
});

[
{
extension: '.js',
plugins: [...baseBundleConfig.plugins, commonjs()],
},
{
extension: '.min.js',
plugins: [...baseBundleConfig.plugins, commonjs(), terserPlugin],
},
].forEach(build => {
builds.push({
...baseBundleConfig,
input: `src/${file}`,
output: {
...baseBundleConfig.output,
...addOnBundleConfig.output,
file: `build/${file.replace('.ts', build.extension)}`,
file: `${baseBundleConfig.output.file}${build.extension}`,
},
plugins: build.plugins,
})),
);
});
});
});

return builds;
}

Expand Down