-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrollup.config.js
More file actions
42 lines (37 loc) · 1.02 KB
/
rollup.config.js
File metadata and controls
42 lines (37 loc) · 1.02 KB
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
import clean from '@rollup-extras/plugin-clean';
import fs from 'fs-extra';
import { fileURLToPath } from 'node:url';
import { dts } from 'rollup-plugin-dts';
import { globSync } from 'tinyglobby';
function getEntries() {
const pkg = fs.readJsonSync('package.json');
const globPatterns = Object.entries(pkg.exports)
.flatMap(([, value]) => [value.default, value.browser, value.node])
.filter((o) => o != null)
.map((value) => value.replace(/\*/, '**/*.js'));
const staticEntries = Object.fromEntries(
globSync([
...globPatterns,
// our handwritten types
'src/**/*.d.ts',
'esm/**/*.d.ts',
]).map((file) => {
return [
file.replace(new RegExp('\\.d\\.ts$'), '').replace(new RegExp('\\.js$'), ''),
fileURLToPath(new URL(file, import.meta.url)),
];
}),
);
return staticEntries;
}
export default [
{
input: getEntries(),
output: {
format: 'es',
dir: 'dist/types',
preserveModules: true,
},
plugins: [clean(), dts()],
},
];