|
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 | + 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({ |
56 | 32 | ...baseBundleConfig, |
57 | | - input: `src/${file}`, |
58 | 33 | output: { |
59 | 34 | ...baseBundleConfig.output, |
60 | | - ...addOnBundleConfig.output, |
61 | | - file: `build/${file.replace('.ts', build.extension)}`, |
| 35 | + file: `${baseBundleConfig.output.file}${build.extension}`, |
62 | 36 | }, |
63 | 37 | plugins: build.plugins, |
64 | | - })), |
65 | | - ); |
| 38 | + }); |
| 39 | + }); |
66 | 40 | }); |
| 41 | + |
67 | 42 | return builds; |
68 | 43 | } |
69 | 44 |
|
|
0 commit comments