-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
50 lines (42 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
49
50
import typescript from 'rollup-plugin-typescript2';
import { tmpdir } from 'os';
import { builtinModules } from 'module';
import { join as pathJoin } from 'path';
import pkg from './package.json';
const cacheRoot = pathJoin(tmpdir(), '.rpt2_cache');
const CORE_MODULE_RE = /(^_|\/)/;
const coreModules = builtinModules.filter(name => (
!CORE_MODULE_RE.test(name)
));
const src = pathJoin(__dirname, 'src');
const lib = pathJoin(__dirname, 'lib');
export default {
input: pathJoin(src, 'index.ts'),
plugins: [
typescript({
cacheRoot,
declarationDir: lib,
tsconfigOverride: {
outDir: lib,
rootDir: src,
include: [src]
}
})
],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...coreModules
],
output: [
{
file: pathJoin(lib, 'index.js'),
format: 'cjs',
exports: 'named'
},
{
file: pathJoin(lib, 'index.mjs'),
format: 'esm'
}
]
};