build: switch to pnpm
[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 ],
23ff945a 37 external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'],
660940b0 38 plugins: [
8f98d75d 39 typescript({
660940b0
JB
40 tsconfig: isDevelopmentBuild
41 ? 'tsconfig.development.json'
ce68dd22 42 : 'tsconfig.production.json'
660940b0
JB
43 }),
44 del({
f4162974 45 targets: ['lib/*']
f45e4999 46 }),
5ea22628 47 isAnalyze && analyze(),
186b35b6 48 isDocumentation && command('pnpm run typedoc')
660940b0
JB
49 ]
50}