-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
62 lines (58 loc) · 1.6 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
import { resolve } from 'path';
import { RollupOptions } from 'rollup';
import dts from 'rollup-plugin-dts';
import esbuild from 'rollup-plugin-esbuild';
import { localImport } from 'rollup-plugin-local-import';
const entries = [
'index',
'to-be-announced',
'jest/index',
'jest/register',
'vitest/index',
'vitest/register',
] as const;
export default entries
.map((entry): RollupOptions[] => {
const input = `./src/${entry}.ts`;
function external(filename: string) {
return filename !== resolve(input);
}
return [
{
input,
output: {
file: `dist/${entry}.js`,
format: 'cjs',
exports: 'auto',
interop: 'compat',
},
plugins: [
esbuild(),
localImport((filename) => `${filename}.js`),
],
external,
},
{
input,
output: {
file: `dist/${entry}.mjs`,
format: 'esm',
},
plugins: [
esbuild(),
localImport((filename) => `${filename}.mjs`),
],
external,
},
{
input,
output: {
file: `dist/${entry}.d.ts`,
format: 'esm',
},
plugins: [esbuild(), dts()],
external,
},
];
})
.flat();