fix: execute() can have no arguments in examples
[poolifier.git] / rollup.config.mjs
CommitLineData
8424fb0d 1import { cpus } from 'node:os'
8f98d75d
JB
2import terser from '@rollup/plugin-terser'
3import typescript from '@rollup/plugin-typescript'
f45e4999 4import analyze from 'rollup-plugin-analyzer'
5ea22628 5import command from 'rollup-plugin-command'
eae1fc25 6import del from 'rollup-plugin-delete'
660940b0
JB
7
8const isDevelopmentBuild = process.env.BUILD === 'development'
9dc351aa
JB
9const isAnalyzeBuild = process.env.ANALYZE
10const isDocumentationBuild = process.env.DOCUMENTATION
660940b0 11
1a89e646 12const maxWorkers = Math.floor(cpus().length / 2)
509e904b 13
660940b0
JB
14export default {
15 input: 'src/index.ts',
f1dbb029 16 strictDeprecations: true,
34a0cfab
JB
17 output: [
18 {
34a0cfab 19 format: 'cjs',
34a0cfab 20 ...(isDevelopmentBuild && {
5119cf1a 21 dir: 'lib',
aef30681 22 sourcemap: true,
34a0cfab
JB
23 preserveModules: true,
24 preserveModulesRoot: 'src'
25 }),
5119cf1a
JB
26 ...(!isDevelopmentBuild && {
27 file: 'lib/index.js',
509e904b 28 plugins: [terser({ maxWorkers })]
5119cf1a 29 })
34a0cfab
JB
30 },
31 {
34a0cfab 32 format: 'esm',
34a0cfab 33 ...(isDevelopmentBuild && {
5119cf1a 34 dir: 'lib',
aef30681 35 sourcemap: true,
34a0cfab
JB
36 entryFileNames: '[name].mjs',
37 preserveModules: true,
38 preserveModulesRoot: 'src'
39 }),
5119cf1a
JB
40 ...(!isDevelopmentBuild && {
41 file: 'lib/index.mjs',
509e904b 42 plugins: [terser({ maxWorkers })]
5119cf1a 43 })
34a0cfab
JB
44 }
45 ],
fc3e6586
JB
46 external: [
47 'node:async_hooks',
48 'node:cluster',
49 'node:crypto',
50 'node:events',
3d6dd312 51 'node:fs',
fc3e6586 52 'node:os',
62c15a68 53 'node:perf_hooks',
fc3e6586
JB
54 'node:worker_threads'
55 ],
660940b0 56 plugins: [
8f98d75d 57 typescript({
660940b0
JB
58 tsconfig: isDevelopmentBuild
59 ? 'tsconfig.development.json'
ce68dd22 60 : 'tsconfig.production.json'
660940b0
JB
61 }),
62 del({
f4162974 63 targets: ['lib/*']
f45e4999 64 }),
9dc351aa
JB
65 isAnalyzeBuild && analyze(),
66 isDocumentationBuild && command('pnpm typedoc')
660940b0
JB
67 ]
68}