refactor: conditionally reset strategy internals
[poolifier.git] / rollup.config.mjs
CommitLineData
8f98d75d
JB
1import terser from '@rollup/plugin-terser'
2import typescript from '@rollup/plugin-typescript'
f45e4999 3import analyze from 'rollup-plugin-analyzer'
5ea22628 4import command from 'rollup-plugin-command'
eae1fc25 5import del from 'rollup-plugin-delete'
660940b0
JB
6
7const isDevelopmentBuild = process.env.BUILD === 'development'
f4162974 8const isAnalyze = process.env.ANALYZE
5ea22628 9const isDocumentation = process.env.DOCUMENTATION
660940b0
JB
10
11export default {
12 input: 'src/index.ts',
f1dbb029 13 strictDeprecations: true,
34a0cfab
JB
14 output: [
15 {
16 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
17 format: 'cjs',
18 sourcemap: !!isDevelopmentBuild,
19 ...(isDevelopmentBuild && {
20 preserveModules: true,
21 preserveModulesRoot: 'src'
22 }),
23 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
24 },
25 {
26 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.mjs' }),
27 format: 'esm',
28 sourcemap: !!isDevelopmentBuild,
34a0cfab
JB
29 ...(isDevelopmentBuild && {
30 entryFileNames: '[name].mjs',
31 preserveModules: true,
32 preserveModulesRoot: 'src'
33 }),
34 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
35 }
36 ],
fc3e6586
JB
37 external: [
38 'node:async_hooks',
39 'node:cluster',
40 'node:crypto',
41 'node:events',
42 'node:os',
43 'node:worker_threads'
44 ],
660940b0 45 plugins: [
8f98d75d 46 typescript({
660940b0
JB
47 tsconfig: isDevelopmentBuild
48 ? 'tsconfig.development.json'
ce68dd22 49 : 'tsconfig.production.json'
660940b0
JB
50 }),
51 del({
f4162974 52 targets: ['lib/*']
f45e4999 53 }),
5ea22628 54 isAnalyze && analyze(),
186b35b6 55 isDocumentation && command('pnpm run typedoc')
660940b0
JB
56 ]
57}