-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.mjs
33 lines (29 loc) · 1.11 KB
/
rollup.config.mjs
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
import { defineConfig } from 'rollup';
import typescript from '@rollup/plugin-typescript';
const external = ['zustand', 'zustand/middleware', 'zustand/traditional', 'rxjs', 'immer', 'react', 'react-tracked', 'proxy-compare'];
const createTypesConfig = (input) => {
return defineConfig({
input,
external,
output: { dir: 'dist' },
plugins: [typescript({ tsconfig: './tsconfig.build.json', declaration: true, declarationDir: 'dist/types' })],
});
};
const createBuildConfig = (input, name) => {
return defineConfig({
input,
external,
output: [
{ file: `./dist/esm/${name}.mjs`, format: 'es' },
{ file: `./dist/esm/${name}.js`, format: 'es' },
{ file: `./dist/${name}.js`, format: 'cjs' },
],
plugins: [typescript({ tsconfig: './tsconfig.build.json', removeComments: true })],
});
};
const entries = [
{ input: './src/index.ts', name: 'index' },
{ input: './src/effect.ts', name: 'effect' },
{ input: './src/tracked.ts', name: 'tracked' },
];
export default defineConfig(entries.flatMap(({ input, name }) => [createTypesConfig(input), createBuildConfig(input, name)]));