-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
50 lines (45 loc) · 1.16 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
import typescript from "@rollup/plugin-typescript";
const items = [];
const modules = [
// Modules exported from `index.ts` can be imported directly:
//
// ```tsx
// // index.ts
// export { utils } from "./utils";
//
// // userland code
// import { utils } from "package-name";
// ```
//
"index",
// Modules added here can be imported directory.
//
// E.g. adding "utils" would allow imports like so:
//
// ```tsx
// import utils from "package-name/utils";
// ```
//
];
for (const module of modules) {
const input =
module === "index" ? `src/${module}.ts` : `src/${module}/index.ts`;
const output = module === "index" ? `dist/${module}` : `dist/${module}/index`;
items.push({
input,
external: [],
output: [
{ file: `${output}.js`, format: "cjs", exports: "auto" },
{ file: `${output}.esm.js`, format: "es" },
],
plugins: [
typescript({
tsconfig: "./tsconfig.json",
// Only generate declarations once
declaration: module === "index",
declarationDir: module === "index" ? "." : undefined,
}),
],
});
}
export default items;