-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrollup.config.js
96 lines (94 loc) · 1.6 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
import { nodeResolve } from '@rollup/plugin-node-resolve'
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
import packageJson from './package.json' assert { type: 'json' }
const plugins = [nodeResolve({ modulesOnly: true })]
const pluginsCjs = [
...plugins,
getBabelOutputPlugin({
presets: [
[
'@babel/preset-env',
{
targets: {
node: '12',
},
},
],
],
}),
]
const external = [
...Object.keys(packageJson.dependencies),
...Object.keys(packageJson.peerDependencies),
]
console.log('External packages:', external)
const [, , , _mode] = process.argv
const mode = _mode === '--esm' ? 'es' : _mode === '--cjs' ? 'cjs' : undefined
export default [
{
input: 'dist/lib/index.js',
external,
output: [
{
file: 'dist/index.mjs',
format: 'es',
},
],
plugins,
},
{
input: 'dist/lib/index.js',
external,
output: [
{
file: 'dist/index.js',
format: 'cjs',
},
],
plugins: pluginsCjs,
},
{
external,
input: 'dist/lib/l2/index.js',
output: [
{
file: './l2/index.mjs',
format: 'es',
},
],
plugins,
},
{
external,
input: 'dist/lib/l2/index.js',
output: [
{
file: './l2/index.js',
format: 'cjs',
},
],
plugins: pluginsCjs,
},
{
external,
input: 'dist/lib/agent/index.js',
output: [
{
file: './agent/index.mjs',
format: 'es',
},
],
plugins,
},
{
external,
input: 'dist/lib/agent/index.js',
output: [
{
file: './agent/index.js',
format: 'cjs',
},
],
plugins: pluginsCjs,
},
].filter((x) => (mode ? x.output.every(({ format }) => format === mode) : x))