1 import analyze from 'rollup-plugin-analyzer'
2 import command from 'rollup-plugin-command'
3 import del from 'rollup-plugin-delete'
4 import istanbul from 'rollup-plugin-istanbul'
5 import { terser } from 'rollup-plugin-terser'
6 import ts from 'rollup-plugin-ts'
8 const isDevelopmentBuild = process.env.BUILD === 'development'
9 const isAnalyze = process.env.ANALYZE
10 const isDocumentation = process.env.DOCUMENTATION
13 input: 'src/index.ts',
15 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
17 sourcemap: !!isDevelopmentBuild,
18 ...(isDevelopmentBuild && { preserveModules: true }),
19 ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
20 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] })
22 external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'],
25 tsconfig: isDevelopmentBuild
26 ? 'tsconfig.development.json'
30 isDevelopmentBuild && istanbul(),
34 isAnalyze && analyze(),
35 isDocumentation && command('npm run typedoc')