1 import { cpus } from 'node:os'
2 import terser from '@rollup/plugin-terser'
3 import typescript from '@rollup/plugin-typescript'
4 import analyze from 'rollup-plugin-analyzer'
5 import command from 'rollup-plugin-command'
6 import del from 'rollup-plugin-delete'
8 const isDevelopmentBuild = process.env.BUILD === 'development'
9 const isAnalyzeBuild = process.env.ANALYZE
10 const isDocumentationBuild = process.env.DOCUMENTATION
12 const maxWorkers = cpus().length / 2
15 input: 'src/index.ts',
16 strictDeprecations: true,
20 ...(isDevelopmentBuild && {
23 preserveModules: true,
24 preserveModulesRoot: 'src'
26 ...(!isDevelopmentBuild && {
28 plugins: [terser({ maxWorkers })]
33 ...(isDevelopmentBuild && {
36 entryFileNames: '[name].mjs',
37 preserveModules: true,
38 preserveModulesRoot: 'src'
40 ...(!isDevelopmentBuild && {
41 file: 'lib/index.mjs',
42 plugins: [terser({ maxWorkers })]
57 tsconfig: isDevelopmentBuild
58 ? 'tsconfig.development.json'
59 : 'tsconfig.production.json'
64 isAnalyzeBuild && analyze(),
65 isDocumentationBuild && command('pnpm typedoc')