-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
rollup.config.js
52 lines (50 loc) · 1.08 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
51
52
import { swc } from 'rollup-plugin-swc3'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import nodeEsm from '@trigen/browserslist-config/node-esm'
import shebang from 'rollup-plugin-add-shebang'
import pkg from './package.json' assert { type: 'json' }
const extensions = ['.js', '.ts']
const external = _ => /node_modules/.test(_) && !/@swc\/helpers/.test(_)
const plugins = targets => [
nodeResolve({
extensions
}),
swc({
tsconfig: false,
jsc: {
parser: {
syntax: 'typescript'
},
externalHelpers: true
},
env: {
targets
},
module: {
type: 'es6'
},
sourceMaps: true
})
]
export default [
{
input: pkg.exports,
plugins: plugins(nodeEsm.join(', ')),
external,
output: {
file: pkg.publishConfig.exports.import,
format: 'es',
sourcemap: true
}
},
{
input: 'src/cli.ts',
plugins: [...plugins(nodeEsm.join(', ')), shebang()],
external: _ => !_.endsWith('src/cli.ts'),
output: {
file: 'dist/cli.js',
format: 'es',
sourcemap: true
}
}
]