1 import typescript from 'rollup-plugin-typescript2'
2 import analyze from 'rollup-plugin-analyzer'
3 import { terser } from 'rollup-plugin-terser'
4 import del from 'rollup-plugin-delete'
5 import command from 'rollup-plugin-command'
7 const isDevelopmentBuild = process.env.BUILD === 'development'
8 const isAnalyze = process.env.ANALYZE
9 const isDocumentation = process.env.DOCUMENTATION
12 input: 'src/index.ts',
14 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
16 sourcemap: !!isDevelopmentBuild,
17 ...(isDevelopmentBuild && { preserveModules: true }),
18 ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
19 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] })
21 external: ['async_hooks', 'cluster', 'events', 'worker_threads'],
24 tsconfig: isDevelopmentBuild
25 ? 'tsconfig.development.json'
31 isAnalyze && analyze(),
32 isDocumentation && command('npm run typedoc')