|
1 | 1 | import * as fs from 'fs';
|
2 | 2 |
|
3 |
| -import { terser } from 'rollup-plugin-terser'; |
4 | 3 | import commonjs from '@rollup/plugin-commonjs';
|
5 | 4 |
|
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'; |
37 | 6 |
|
38 | 7 | function allIntegrations() {
|
39 | 8 | return fs.readdirSync('./src').filter(file => file != 'index.ts');
|
40 | 9 | }
|
41 | 10 |
|
42 | 11 | function loadAllIntegrations() {
|
43 | 12 | 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 | + jsVersion: 'es5', |
| 19 | + outputFileBase: `build/${file.replace('.ts', '')}`, |
| 20 | + }); |
| 21 | + |
| 22 | + [ |
| 23 | + { |
| 24 | + extension: '.js', |
| 25 | + plugins: [...baseBundleConfig.plugins, commonjs()], |
| 26 | + }, |
| 27 | + { |
| 28 | + extension: '.min.js', |
| 29 | + plugins: [...baseBundleConfig.plugins, commonjs(), terserPlugin], |
| 30 | + }, |
| 31 | + ].forEach(build => { |
| 32 | + builds.push({ |
56 | 33 | ...baseBundleConfig,
|
57 |
| - input: `src/${file}`, |
58 | 34 | output: {
|
59 | 35 | ...baseBundleConfig.output,
|
60 |
| - ...addOnBundleConfig.output, |
61 |
| - file: `build/${file.replace('.ts', build.extension)}`, |
| 36 | + file: `${baseBundleConfig.output.file}${build.extension}`, |
62 | 37 | },
|
63 | 38 | plugins: build.plugins,
|
64 |
| - })), |
65 |
| - ); |
| 39 | + }); |
| 40 | + }); |
66 | 41 | });
|
| 42 | + |
67 | 43 | return builds;
|
68 | 44 | }
|
69 | 45 |
|
|
0 commit comments