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