forked from LegendApp/legend-state
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
64 lines (57 loc) · 1.75 KB
/
rollup.config.ts
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
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
// @ts-ignore
import pkg from './package.json';
export default Object.keys(pkg.exports)
.filter((exp) => exp !== './types')
.map((exp) => {
if (exp.endsWith('json')) return;
let f = exp.slice(2);
const external = [
'react',
'react-native',
'react-native-mmkv',
'@legendapp/state',
'@legendapp/state/persist',
'@legendapp/state/react',
];
if (!f) f = 'index';
const output = [
{
file: './dist/' + f + '.js',
format: 'cjs',
sourcemap: true,
},
];
if (exp === './babel') {
// @ts-ignore
output[0].exports = 'default';
} else {
output.push({
file: './dist/' + f + '.mjs',
format: 'es',
sourcemap: true,
});
}
return {
input: './' + f + '.ts',
output,
external: external,
plugins: [
resolve(),
commonjs(),
typescript({
outputToFilesystem: true,
paths: {
react: ['node_modules/react'],
'react-native': ['node_modules/react-native'],
'@legendapp/state': ['./index'],
'@legendapp/state/persist': ['./persist'],
'@legendapp/state/react': ['./react'],
},
}),
],
};
})
.filter((a) => a);