-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
39 lines (37 loc) · 1.02 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
import path from 'path'
import typescript from 'rollup-plugin-typescript2'
import findCacheDir from 'find-cache-dir'
const resolveCwd = path.resolve.bind(null, process.cwd())
const pkg = require(resolveCwd('package.json'))
const deps = Object.keys({...pkg.dependencies, ...pkg.peerDependencies})
const reExternal = new RegExp(`^(${deps.join('|')})($|/)`)
export default [
{
input: pkg.source,
output: [
{
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'esm',
},
],
plugins: [
pkg.source.endsWith('.ts') &&
typescript({
cacheRoot: findCacheDir({
name: 'rollup-plugin-typescript2',
cwd: __dirname,
}),
tsconfigOverride: {
include: ['**/*'],
exclude: ['**/*.spec.*', '**/__tests__', './test.ts'],
compilerOptions: {target: 'ES6'},
},
}),
].filter(Boolean),
external: (id) => (deps.length ? reExternal.test(id) : false),
},
]