-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
executable file
·89 lines (78 loc) · 1.48 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
import path from 'path';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
const input = './src/lib/index.js';
let logged = {};
const external = id => {
// external
if ([
'react',
'react-dom',
].includes(id)) {
return true;
}
// external
if (id.startsWith('@babel')) {
return true;
}
// internal
if (id.startsWith('.') || path.isAbsolute(id)) {
return false;
}
// internal
if ([
// 'react-window',
// 'react-virtualized-auto-sizer',
// 'react-window-infinite-loader',
// 'react-image-crop',
// 'copy-to-clipboard',
// 'memoize-one',
// 'prop-types',
// 'react-is',
// 'object-assign',
].includes(id)) {
return false;
}
// log other externals
if (!logged[id]) {
console.log('->', id);
logged[id] = true;
}
// external
return true;
};
export default [
{
input,
output: {
dir: 'build/',
format: 'cjs',
},
external,
plugins: [
babel({
runtimeHelpers: true,
plugins: ['@babel/transform-runtime'],
}),
nodeResolve(),
commonjs(),
],
},
{
input,
output: {
dir: 'build/esm/',
format: 'esm',
},
external,
plugins: [
babel({
runtimeHelpers: true,
plugins: [['@babel/transform-runtime', { useESModules: true }]],
}),
nodeResolve(),
commonjs(),
],
},
];