Document worker choice strategies. (#345)
[poolifier.git] / rollup.config.mjs
CommitLineData
7977150f 1import typescript from 'rollup-plugin-typescript2'
f45e4999
JB
2import analyze from 'rollup-plugin-analyzer'
3import { terser } from 'rollup-plugin-terser'
660940b0 4import del from 'rollup-plugin-delete'
5ea22628 5import command from 'rollup-plugin-command'
660940b0
JB
6
7const isDevelopmentBuild = process.env.BUILD === 'development'
f4162974 8const isAnalyze = process.env.ANALYZE
5ea22628 9const isDocumentation = process.env.DOCUMENTATION
660940b0
JB
10
11export default {
12 input: 'src/index.ts',
f4162974
JB
13 output: {
14 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
15 format: 'cjs',
16 sourcemap: !!isDevelopmentBuild,
17 ...(isDevelopmentBuild && { preserveModules: true }),
18 ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
19 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] })
20 },
660940b0
JB
21 external: ['async_hooks', 'cluster', 'events', 'worker_threads'],
22 plugins: [
7977150f 23 typescript({
660940b0
JB
24 tsconfig: isDevelopmentBuild
25 ? 'tsconfig.development.json'
26 : 'tsconfig.json'
27 }),
28 del({
f4162974 29 targets: ['lib/*']
f45e4999 30 }),
5ea22628
JB
31 isAnalyze && analyze(),
32 isDocumentation && command('npm run typedoc')
660940b0
JB
33 ]
34}