Skip to content

Commit d520fe3

Browse files
lobsterkatieAbhiPrasad
authored andcommitted
ref(build): Use base rollup config function in @sentry/integrations (#4652)
This uses the config-generating function introduced in #4650 to generate the rollup config for the integrations package. There is no effect on bundle contents.
1 parent 61184e5 commit d520fe3

File tree

1 file changed

+24
-49
lines changed

1 file changed

+24
-49
lines changed

packages/integrations/rollup.config.js

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,44 @@
11
import * as fs from 'fs';
22

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

6-
import {
7-
addOnBundleConfig,
8-
baseBundleConfig,
9-
markAsBrowserBuild,
10-
nodeResolvePlugin,
11-
typescriptPluginES5,
12-
} from '../../rollup.config';
13-
14-
const terserInstance = terser({
15-
mangle: {
16-
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
17-
// as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version.
18-
// We need those full names to correctly detect our internal frames for stripping.
19-
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
20-
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
21-
properties: {
22-
regex: /^_[^_]/,
23-
},
24-
},
25-
output: {
26-
comments: false,
27-
},
28-
});
29-
30-
const plugins = [
31-
typescriptPluginES5,
32-
// replace `__SENTRY_BROWSER_BUNDLE__` with `true` to enable treeshaking of non-browser code
33-
markAsBrowserBuild,
34-
nodeResolvePlugin,
35-
commonjs(),
36-
];
5+
import { makeBaseBundleConfig, terserPlugin } from '../../rollup.config';
376

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

4211
function loadAllIntegrations() {
4312
const builds = [];
44-
[
45-
{
46-
extension: '.js',
47-
plugins,
48-
},
49-
{
50-
extension: '.min.js',
51-
plugins: [...plugins, terserInstance],
52-
},
53-
].forEach(build => {
54-
builds.push(
55-
...allIntegrations().map(file => ({
13+
14+
allIntegrations().forEach(file => {
15+
const baseBundleConfig = makeBaseBundleConfig({
16+
input: `src/${file}`,
17+
isAddOn: true,
18+
outputFileBase: `build/${file.replace('.ts', '')}`,
19+
});
20+
21+
[
22+
{
23+
extension: '.js',
24+
plugins: [...baseBundleConfig.plugins, commonjs()],
25+
},
26+
{
27+
extension: '.min.js',
28+
plugins: [...baseBundleConfig.plugins, commonjs(), terserPlugin],
29+
},
30+
].forEach(build => {
31+
builds.push({
5632
...baseBundleConfig,
57-
input: `src/${file}`,
5833
output: {
5934
...baseBundleConfig.output,
60-
...addOnBundleConfig.output,
61-
file: `build/${file.replace('.ts', build.extension)}`,
35+
file: `${baseBundleConfig.output.file}${build.extension}`,
6236
},
6337
plugins: build.plugins,
64-
})),
65-
);
38+
});
39+
});
6640
});
41+
6742
return builds;
6843
}
6944

0 commit comments

Comments
 (0)