-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
52 lines (40 loc) · 999 Bytes
/
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
const typescript = require('@rollup/plugin-typescript');
const babel = require('@rollup/plugin-babel');
const path = require('path');
// eslint-disable-next-line import/no-dynamic-require
const pkg = require(path.resolve('package.json'));
const tsOpts = {
tsconfig: `${__dirname}/tsconfig.json`,
};
const babelOpts = {
babelrc: false,
presets: [['@babel/preset-env', { targets: { node: '12' } }]],
plugins: ['@babel/plugin-transform-runtime'],
babelHelpers: 'runtime',
};
const external = [/@babel\/runtime/, /@debugr\//];
if (pkg.build.externals) {
external.push(...pkg.build.externals);
}
module.exports = [
{
input: pkg.build.src,
plugins: [typescript(tsOpts), babel(babelOpts)],
external,
output: {
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
},
{
input: pkg.build.src,
plugins: [typescript(tsOpts)],
external,
output: {
file: pkg.module,
format: 'esm',
sourcemap: true,
},
},
];