build: enforce strict deprecation checks
[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,
29
30 ...(isDevelopmentBuild && {
31 entryFileNames: '[name].mjs',
32 preserveModules: true,
33 preserveModulesRoot: 'src'
34 }),
35 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
36 }
37 ],
23ff945a 38 external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'],
660940b0 39 plugins: [
8f98d75d 40 typescript({
660940b0
JB
41 tsconfig: isDevelopmentBuild
42 ? 'tsconfig.development.json'
ce68dd22 43 : 'tsconfig.production.json'
660940b0
JB
44 }),
45 del({
f4162974 46 targets: ['lib/*']
f45e4999 47 }),
5ea22628
JB
48 isAnalyze && analyze(),
49 isDocumentation && command('npm run typedoc')
660940b0
JB
50 ]
51}