|
1 |
| -import { terser } from 'rollup-plugin-terser'; |
2 |
| -import typescript from 'rollup-plugin-typescript2'; |
| 1 | +import { makeBaseBundleConfig, makeLicensePlugin, terserPlugin } from '../../rollup.config'; |
3 | 2 |
|
4 |
| -import { |
5 |
| - baseBundleConfig, |
6 |
| - makeLicensePlugin, |
7 |
| - markAsBrowserBuild, |
8 |
| - nodeResolvePlugin, |
9 |
| - paths, |
10 |
| - typescriptPluginES5, |
11 |
| -} from '../../rollup.config'; |
| 3 | +const builds = []; |
12 | 4 |
|
13 | 5 | const licensePlugin = makeLicensePlugin();
|
14 | 6 |
|
15 |
| -const terserInstance = terser({ |
16 |
| - compress: { |
17 |
| - // Tell env.ts that we're building a browser bundle and that we do not |
18 |
| - // want to have unnecessary debug functionality. |
19 |
| - global_defs: { |
20 |
| - __SENTRY_NO_DEBUG__: false, |
21 |
| - }, |
22 |
| - }, |
23 |
| - mangle: { |
24 |
| - // captureExceptions and captureMessage are public API methods and they don't need to be listed here |
25 |
| - // as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version. |
26 |
| - // We need those full names to correctly detect our internal frames for stripping. |
27 |
| - // I listed all of them here just for the clarity's sake, as they are all used in the frame-manipulation process. |
28 |
| - reserved: ['captureException', 'captureMessage', 'sentryWrapped'], |
29 |
| - properties: { |
30 |
| - regex: /^_[^_]/, |
31 |
| - // This exclusion prevents most of the occurrences of the bug linked below: |
32 |
| - // https://github.com/getsentry/sentry-javascript/issues/2622 |
33 |
| - // The bug is caused by multiple SDK instances, where one is minified and one is using non-mangled code. |
34 |
| - // Unfortunatelly we cannot fix it reliably (thus `typeof` check in the `InboundFilters` code), |
35 |
| - // as we cannot force people using multiple instances in their apps to sync SDK versions. |
36 |
| - reserved: ['_mergeOptions'], |
37 |
| - }, |
38 |
| - }, |
39 |
| - output: { |
40 |
| - comments: false, |
41 |
| - }, |
42 |
| -}); |
43 |
| - |
44 |
| -const plugins = [ |
45 |
| - typescriptPluginES5, |
46 |
| - // replace `__SENTRY_BROWSER_BUNDLE__` with `true` to enable treeshaking of non-browser code |
47 |
| - markAsBrowserBuild, |
48 |
| - nodeResolvePlugin, |
49 |
| -]; |
50 |
| - |
51 |
| -const bundleConfig = { |
52 |
| - ...baseBundleConfig, |
53 |
| - input: 'src/index.ts', |
54 |
| - output: { |
55 |
| - ...baseBundleConfig.output, |
56 |
| - format: 'iife', |
57 |
| - name: 'Sentry', |
58 |
| - }, |
59 |
| - context: 'window', |
60 |
| - plugins: [...plugins, licensePlugin], |
61 |
| -}; |
| 7 | +['es5', 'es6'].forEach(jsVersion => { |
| 8 | + const baseBundleConfig = makeBaseBundleConfig({ |
| 9 | + input: 'src/index.ts', |
| 10 | + isAddOn: false, |
| 11 | + jsVersion, |
| 12 | + outputFileBase: `build/bundle${jsVersion === 'es6' ? '.es6' : ''}`, |
| 13 | + }); |
62 | 14 |
|
63 |
| -export default [ |
64 |
| - // ES5 Browser Bundle |
65 |
| - { |
66 |
| - ...bundleConfig, |
67 |
| - output: { |
68 |
| - ...bundleConfig.output, |
69 |
| - file: 'build/bundle.js', |
70 |
| - }, |
71 |
| - }, |
72 |
| - { |
73 |
| - ...bundleConfig, |
74 |
| - output: { |
75 |
| - ...bundleConfig.output, |
76 |
| - file: 'build/bundle.min.js', |
77 |
| - }, |
78 |
| - // Uglify has to be at the end of compilation, BUT before the license banner |
79 |
| - plugins: bundleConfig.plugins.slice(0, -1).concat(terserInstance).concat(bundleConfig.plugins.slice(-1)), |
80 |
| - }, |
81 |
| - // ------------------ |
82 |
| - // ES6 Browser Bundle |
83 |
| - { |
84 |
| - ...bundleConfig, |
85 |
| - output: { |
86 |
| - ...bundleConfig.output, |
87 |
| - file: 'build/bundle.es6.js', |
88 |
| - }, |
89 |
| - plugins: [ |
90 |
| - typescript({ |
91 |
| - tsconfig: 'tsconfig.esm.json', |
92 |
| - tsconfigOverride: { |
93 |
| - compilerOptions: { |
94 |
| - declaration: false, |
95 |
| - declarationMap: false, |
96 |
| - paths, |
97 |
| - baseUrl: '.', |
98 |
| - target: 'es6', |
99 |
| - }, |
| 15 | + builds.push( |
| 16 | + ...[ |
| 17 | + { |
| 18 | + ...baseBundleConfig, |
| 19 | + output: { |
| 20 | + ...baseBundleConfig.output, |
| 21 | + file: `${baseBundleConfig.output.file}.js`, |
100 | 22 | },
|
101 |
| - include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'], |
102 |
| - }), |
103 |
| - ...plugins.slice(1).concat(bundleConfig.plugins.slice(-1)), |
104 |
| - ], |
105 |
| - }, |
106 |
| - { |
107 |
| - ...bundleConfig, |
108 |
| - output: { |
109 |
| - ...bundleConfig.output, |
110 |
| - file: 'build/bundle.es6.min.js', |
111 |
| - }, |
112 |
| - plugins: [ |
113 |
| - typescript({ |
114 |
| - tsconfig: 'tsconfig.esm.json', |
115 |
| - tsconfigOverride: { |
116 |
| - compilerOptions: { |
117 |
| - declaration: false, |
118 |
| - declarationMap: false, |
119 |
| - paths, |
120 |
| - baseUrl: '.', |
121 |
| - target: 'es6', |
122 |
| - }, |
| 23 | + plugins: [...baseBundleConfig.plugins, licensePlugin], |
| 24 | + }, |
| 25 | + { |
| 26 | + ...baseBundleConfig, |
| 27 | + output: { |
| 28 | + ...baseBundleConfig.output, |
| 29 | + file: `${baseBundleConfig.output.file}.min.js`, |
123 | 30 | },
|
124 |
| - include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'], |
125 |
| - }), |
126 |
| - ...plugins.slice(1).slice(0, -1).concat(terserInstance).concat(bundleConfig.plugins.slice(-1)), |
| 31 | + plugins: [...baseBundleConfig.plugins, terserPlugin, licensePlugin], |
| 32 | + }, |
127 | 33 | ],
|
128 |
| - }, |
129 |
| - // ------------------ |
130 |
| -]; |
| 34 | + ); |
| 35 | +}); |
| 36 | + |
| 37 | +export default builds; |
0 commit comments