-
Notifications
You must be signed in to change notification settings - Fork 66
/
rollup.config.base.js
96 lines (93 loc) · 2.63 KB
/
rollup.config.base.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
const commonjs = require('@rollup/plugin-commonjs');
const resolve = require('@rollup/plugin-node-resolve');
const terser = require('@rollup/plugin-terser');
const typescript = require('@rollup/plugin-typescript');
const modules = {
core: {
name: '@grafana/faro-core',
bundleName: 'faro-core',
globalName: 'GrafanaFaroCore',
externals: [],
},
react: {
name: '@grafana/react',
bundleName: 'faro-react',
globalName: 'GrafanaFaroReact',
externals: ['webSdk', 'webTracing'],
},
webSdk: {
name: '@grafana/faro-web-sdk',
bundleName: 'faro-web-sdk',
globalName: 'GrafanaFaroWebSdk',
externals: [],
},
webTracing: {
name: '@grafana/faro-web-tracing',
bundleName: 'faro-web-tracing',
globalName: 'GrafanaFaroWebTracing',
externals: ['webSdk'],
},
transportOtlpHttp: {
name: '@grafana/faro-transport-otlp-http',
bundleName: 'faro-transport-otlp-http',
globalName: 'GrafanaFaroTransportOtlpHttp',
externals: [],
},
instrumentationPerformanceTimeline: {
name: '@grafana/faro-instrumentation-performance-timeline',
bundleName: 'faro-instrumentation-performance-timeline',
globalName: 'GrafanaFaroInstrumentationPerformanceTimeline',
externals: [],
},
instrumentationFetch: {
name: '@grafana/faro-instrumentation-fetch',
bundleName: 'faro-instrumentation-fetch',
globalName: 'GrafanaFaroInstrumentationFetch',
externals: [],
},
instrumentationXHR: {
name: '@grafana/faro-instrumentation-xhr',
bundleName: 'faro-instrumentation-xhr',
globalName: 'GrafanaFaroInstrumentationXHR',
externals: [],
},
instrumentationK6Browser: {
name: '@grafana/faro-instrumentation-k6-browser',
bundleName: 'faro-instrumentation-k6-browser',
globalName: 'GrafanaFaroInstrumentationK6Browser',
externals: [],
},
};
exports.getRollupConfigBase = (moduleName) => {
const module = modules[moduleName];
return {
input: './src/index.ts',
output: {
file: `./dist/bundle/${module.bundleName}.iife.js`,
format: 'iife',
globals: module.externals.reduce(
(acc, external) => ({
...acc,
[modules[external].name]: modules[external].globalName,
}),
{}
),
name: module.globalName,
},
external: module.externals.map((external) => modules[external].name),
plugins: [
resolve({
browser: true,
}),
commonjs(),
typescript({
cacheDir: '../../.cache/rollup',
inlineSources: false,
outputToFilesystem: true,
sourceMap: false,
tsconfig: './tsconfig.esm.json',
}),
terser(),
],
};
};