-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
102 lines (97 loc) · 2.32 KB
/
rollup.config.js
File metadata and controls
102 lines (97 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import dts from 'rollup-plugin-dts';
import { readFileSync } from 'fs';
const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'));
// Node-targeted build configuration (CJS + ESM)
const nodeBuildConfig = {
input: 'src/index.ts',
external: [], // No external dependencies - uses native fetch API
output: [
{
file: 'dist/index.cjs.js',
format: 'cjs',
sourcemap: true,
},
{
file: 'dist/index.esm.js',
format: 'esm',
sourcemap: true,
},
{
file: 'dist/index.cjs.min.js',
format: 'cjs',
sourcemap: true,
plugins: [terser()],
},
{
file: 'dist/index.esm.min.js',
format: 'esm',
sourcemap: true,
plugins: [terser()],
},
],
plugins: [
resolve({
// Node-first resolution for these builds
browser: false,
preferBuiltins: true,
}),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
declaration: false, // We'll generate types separately
declarationMap: false,
sourceMap: true,
}),
],
};
// Browser-targeted build configuration (UMD).
// Produces a UMD bundle suitable for <script> inclusion and CDN usage.
const browserBuildConfig = {
input: 'src/index.ts',
external: [],
output: [
{
file: 'dist/index.umd.js',
format: 'umd',
name: packageJson.name || 'WAHA',
sourcemap: true,
globals: {},
},
{
file: 'dist/index.umd.min.js',
format: 'umd',
name: packageJson.name || 'WAHA',
sourcemap: true,
plugins: [terser()],
globals: {},
},
],
plugins: [
// For browser bundles prefer browser field and do not prefer builtins
resolve({
browser: true,
preferBuiltins: false,
}),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
declaration: false,
declarationMap: false,
sourceMap: true,
}),
],
};
// Type definitions build configuration
const dtsConfig = {
input: 'src/index.ts',
output: {
file: 'dist/index.d.ts',
format: 'esm',
},
plugins: [dts()],
};
export default [nodeBuildConfig, browserBuildConfig, dtsConfig];