-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.js
48 lines (45 loc) · 1.12 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
import fs from 'node:fs'
import path from 'node:path'
import babel from '@rollup/plugin-babel'
import del from 'rollup-plugin-delete'
import typescript from '@rollup/plugin-typescript';
const packageJson = JSON.parse(fs.readFileSync('./package.json'))
export default [
{
input: Object.fromEntries(
Object.keys(packageJson.exports).map((chunk) => {
const source = packageJson.exports[chunk].default
.replace("/lib/", "/src/")
.replace(".mjs", ".ts");
const entry = source.replace(/\.\/src\/|\.ts/g, "");
return [entry, source];
}),
),
output: [
{
dir: 'lib',
format: 'es',
preserveModules: true,
entryFileNames: '[name].mjs'
},
{
dir: 'lib',
format: 'cjs',
preserveModules: true,
entryFileNames: '[name].cjs'
}
],
external: [
'moize',
'confusables'
],
plugins: [
del({ targets: 'lib/*' }),
babel({
babelHelpers: 'bundled',
extensions: ['.js', '.ts']
}),
typescript({tsconfig: './tsconfig.build.json'})
],
}
]