1 import terser from '@rollup/plugin-terser'
2 import typescript from '@rollup/plugin-typescript'
3 import analyze from 'rollup-plugin-analyzer'
4 import command from 'rollup-plugin-command'
5 import del from 'rollup-plugin-delete'
7 const isDevelopmentBuild = process.env.BUILD === 'development'
8 const isAnalyze = process.env.ANALYZE
9 const isDocumentation = process.env.DOCUMENTATION
12 input: 'src/index.ts',
13 strictDeprecations: true,
16 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
18 sourcemap: !!isDevelopmentBuild,
19 ...(isDevelopmentBuild && {
20 preserveModules: true,
21 preserveModulesRoot: 'src'
23 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
26 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.mjs' }),
28 sourcemap: !!isDevelopmentBuild,
30 ...(isDevelopmentBuild && {
31 entryFileNames: '[name].mjs',
32 preserveModules: true,
33 preserveModulesRoot: 'src'
35 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
38 external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'],
41 tsconfig: isDevelopmentBuild
42 ? 'tsconfig.development.json'
43 : 'tsconfig.production.json'
48 isAnalyze && analyze(),
49 isDocumentation && command('npm run typedoc')