|
| 1 | +import { terser } from 'rollup-plugin-terser'; |
| 2 | +import typescript from 'rollup-plugin-typescript2'; |
| 3 | +import license from 'rollup-plugin-license'; |
| 4 | +import resolve from 'rollup-plugin-node-resolve'; |
| 5 | +import commonjs from 'rollup-plugin-commonjs'; |
| 6 | + |
| 7 | +const commitHash = require('child_process') |
| 8 | + .execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }) |
| 9 | + .trim(); |
| 10 | + |
| 11 | +const terserInstance = terser({ |
| 12 | + mangle: { |
| 13 | + // captureExceptions and captureMessage are public API methods and they don't need to be listed here |
| 14 | + // as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version. |
| 15 | + // We need those full names to correctly detect our internal frames for stripping. |
| 16 | + // I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process. |
| 17 | + reserved: ['captureException', 'captureMessage', 'sentryWrapped'], |
| 18 | + properties: { |
| 19 | + regex: /^_[^_]/, |
| 20 | + }, |
| 21 | + }, |
| 22 | +}); |
| 23 | + |
| 24 | +const paths = { |
| 25 | + '@sentry/utils': ['../utils/src'], |
| 26 | + '@sentry/core': ['../core/src'], |
| 27 | + '@sentry/hub': ['../hub/src'], |
| 28 | + '@sentry/types': ['../types/src'], |
| 29 | + '@sentry/minimal': ['../minimal/src'], |
| 30 | + '@sentry/browser': ['../browser/src'], |
| 31 | +}; |
| 32 | + |
| 33 | +const plugins = [ |
| 34 | + typescript({ |
| 35 | + tsconfig: 'tsconfig.build.json', |
| 36 | + tsconfigOverride: { |
| 37 | + compilerOptions: { |
| 38 | + declaration: false, |
| 39 | + declarationMap: false, |
| 40 | + module: 'ES2015', |
| 41 | + paths, |
| 42 | + }, |
| 43 | + }, |
| 44 | + include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'], |
| 45 | + }), |
| 46 | + resolve({ |
| 47 | + mainFields: ['module'], |
| 48 | + }), |
| 49 | + commonjs(), |
| 50 | +]; |
| 51 | + |
| 52 | +const bundleConfig = { |
| 53 | + input: 'src/index.ts', |
| 54 | + output: { |
| 55 | + format: 'iife', |
| 56 | + name: 'Sentry', |
| 57 | + sourcemap: true, |
| 58 | + strict: false, |
| 59 | + }, |
| 60 | + context: 'window', |
| 61 | + plugins: [ |
| 62 | + ...plugins, |
| 63 | + license({ |
| 64 | + sourcemap: true, |
| 65 | + banner: `/*! @sentry/vue <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/sentry-javascript */`, |
| 66 | + }), |
| 67 | + ], |
| 68 | +}; |
| 69 | + |
| 70 | +export default [ |
| 71 | + // ES5 Browser Tracing Bundle |
| 72 | + { |
| 73 | + ...bundleConfig, |
| 74 | + input: 'src/index.bundle.ts', |
| 75 | + output: { |
| 76 | + ...bundleConfig.output, |
| 77 | + file: 'build/bundle.vue.js', |
| 78 | + }, |
| 79 | + plugins: bundleConfig.plugins, |
| 80 | + }, |
| 81 | + { |
| 82 | + ...bundleConfig, |
| 83 | + input: 'src/index.bundle.ts', |
| 84 | + output: { |
| 85 | + ...bundleConfig.output, |
| 86 | + file: 'build/bundle.vue.min.js', |
| 87 | + }, |
| 88 | + // Uglify has to be at the end of compilation, BUT before the license banner |
| 89 | + plugins: bundleConfig.plugins |
| 90 | + .slice(0, -1) |
| 91 | + .concat(terserInstance) |
| 92 | + .concat(bundleConfig.plugins.slice(-1)), |
| 93 | + }, |
| 94 | +]; |
0 commit comments