-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
65 lines (62 loc) · 1.58 KB
/
rollup.config.mjs
File metadata and controls
65 lines (62 loc) · 1.58 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import path from "node:path";
import { globSync } from "glob";
import { fileURLToPath } from "node:url";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
/**
* Helper to get all the .test.ts files for compiling tests
*
* @returns The list of test input files
*/
function getTestFiles() {
return Object.fromEntries(
globSync("src/**/*.test.ts").map((file) => [
// This remove `src/` as well as the file extension from each
// file, so e.g. src/nested/foo.js becomes nested/foo
path.relative(
"src",
file.slice(0, file.length - path.extname(file).length)
),
// This expands the relative paths to absolute paths, so e.g.
// src/nested/foo becomes /project/src/nested/foo.js
fileURLToPath(new URL(file, import.meta.url)),
])
);
}
export default [
// Main runtime bundle
{
input: "src/index.ts",
output: [
{
file: "dist/index.cjs",
format: "cjs",
},
{
file: "dist/index.mjs",
format: "es",
},
],
plugins: [
commonjs(),
// Resolve imported modules
nodeResolve(),
// Parse and compile typescript
typescript(),
// Minify output
terser(),
],
},
// Compiled test javascript
// {
// input: getTestFiles(),
// output: {
// dir: 'dist',
// format: 'es'
// },
// plugins: [typescript()],
// external: ['jest'],
// },
];