-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
44 lines (37 loc) · 1.21 KB
/
rollup.config.ts
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
import jsonPlugin from 'rollup-plugin-json';
import typescriptPlugin from 'rollup-plugin-typescript2';
import { tmpdir } from 'os';
import { builtinModules } from 'module';
import { join as pathJoin } from 'path';
const coreModules = builtinModules.filter((name) => !/(^_|\/)/.test(name));
const cacheRoot = pathJoin(tmpdir(), '.rpt2_cache');
export default async function () {
const modulePkg = await import(pathJoin(__dirname, 'package.json'));
return {
input: pathJoin('src', 'index.ts'),
plugins: [
jsonPlugin(),
typescriptPlugin({
cacheRoot,
useTsconfigDeclarationDir: false,
tsconfigOverride: {
outDir: 'lib',
rootDir: 'src',
include: ['src'],
},
}),
],
external: [
...Object.keys(modulePkg.dependencies || {}),
...Object.keys(modulePkg.peerDependencies || {}),
...coreModules,
],
output: [
{
file: pathJoin(__dirname, `${modulePkg.main}.js`),
format: 'cjs',
exports: 'named',
},
],
};
}