Instrument the code at development build for istanbul (#347)
[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'
5519f8f3 6import istanbul from 'rollup-plugin-istanbul'
660940b0
JB
7
8const isDevelopmentBuild = process.env.BUILD === 'development'
f4162974 9const isAnalyze = process.env.ANALYZE
5ea22628 10const isDocumentation = process.env.DOCUMENTATION
660940b0
JB
11
12export default {
13 input: 'src/index.ts',
f4162974
JB
14 output: {
15 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
16 format: 'cjs',
17 sourcemap: !!isDevelopmentBuild,
18 ...(isDevelopmentBuild && { preserveModules: true }),
19 ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
20 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] })
21 },
660940b0
JB
22 external: ['async_hooks', 'cluster', 'events', 'worker_threads'],
23 plugins: [
7977150f 24 typescript({
660940b0
JB
25 tsconfig: isDevelopmentBuild
26 ? 'tsconfig.development.json'
27 : 'tsconfig.json'
28 }),
5519f8f3 29 isDevelopmentBuild && istanbul(),
660940b0 30 del({
f4162974 31 targets: ['lib/*']
f45e4999 32 }),
5ea22628
JB
33 isAnalyze && analyze(),
34 isDocumentation && command('npm run typedoc')
660940b0
JB
35 ]
36}