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