forked from infctr/eslint-plugin-typescript-sort-keys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
37 lines (31 loc) · 1 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
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import json from '@rollup/plugin-json'
import tsconfig from 'tsconfig'
import fs from 'fs'
import assert from 'assert'
const filePath = tsconfig.resolveSync('.')
assert(filePath)
const config = tsconfig.readFileSync(filePath)
const baseUrl = config.compilerOptions.baseUrl
const moduleMappings = fs
.readdirSync(baseUrl, { withFileTypes: true })
.filter(dir => dir.isDirectory())
.map(dir => [dir.name, '/'].join(''))
const external = id =>
!id.startsWith('.') &&
!id.startsWith('/') &&
!id.startsWith('\0') &&
!moduleMappings.some(mapping => id.startsWith(mapping))
export default [
{
input: './src/index.ts',
external,
output: [
{ dir: 'lib', entryFileNames: '[name].cjs.js', format: 'cjs' },
{ dir: 'lib', entryFileNames: '[name].esm.js', format: 'es' },
],
plugins: [commonjs(), resolve(), typescript(), json()],
},
]