-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
56 lines (50 loc) · 1.19 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
49
50
51
52
53
54
55
56
import babel from "@rollup/plugin-babel"
import typescript from "@rollup/plugin-typescript"
import dts from "rollup-plugin-dts"
import { minify } from "rollup-plugin-esbuild-minify"
// node <= v21 experimental: https://github.com/tc39/proposal-import-attributes
import packageJson from "./package.json" with { type: "json" }
const pkg = packageJson
const globals = {
react: "React",
}
const babelOptions = {
babelHelpers: "bundled",
extensions: [".ts", ".tsx"],
exclude: /node_modules/,
}
for (const key of Object.keys(pkg.peerDependencies || {})) {
if (!(key in globals)) {
throw new Error(`Missing peer dependency "${key}" in the globals map.`)
}
}
export default [
{
input: "src/index.ts",
external: Object.keys(globals),
output: [
{
format: "cjs",
file: pkg.main,
exports: "named",
},
{
format: "esm",
file: pkg.module,
exports: "named",
},
],
plugins: [
typescript({
tsconfig: "./tsconfig.json",
}),
babel(babelOptions),
minify(),
],
},
{
input: "./dist/types/src/index.d.ts",
output: [{ file: pkg.types, format: "esm" }],
plugins: [dts()],
},
]