This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
forked from pocketbase/js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
118 lines (109 loc) · 3.3 KB
/
rollup.config.js
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import ts from 'rollup-plugin-ts';
import { terser } from 'rollup-plugin-terser';
const isProduction = !process.env.ROLLUP_WATCH;
function basePlugins() {
return [
ts({
hook: {
outputPath: (path, kind) => {
if (kind === 'declaration') {
// replace .es.d.ts with .es.d.mts (see #92)
//
// this usually is already done in rollup-plugin-ts v3
// and could be removed after upgrading
return path.replace('.es.d.ts', '.es.d.mts');
}
return path;
}
}
}),
// minify if we're building for production
// (aka. npm run build instead of npm run dev)
isProduction && terser({
keep_classnames: true,
keep_fnames: true,
output: {
comments: false,
},
}),
]
}
export default [
// ES bundle (the PocketBase client as default export + additional helper classes).
{
input: 'src/index.ts',
output: [
{
file: 'dist/pocketbase.es.mjs',
format: 'es',
sourcemap: isProduction,
},
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
// ES bundle but with .js extension.
//
// This is needed mainly because of React Native not recognizing the mjs
// extension by default (see https://github.com/pocketbase/js-sdk/issues/47).
{
input: 'src/index.ts',
output: [
{
file: 'dist/pocketbase.es.js',
format: 'es',
sourcemap: isProduction,
},
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
// UMD bundle (only the PocketBase client as default export).
{
input: 'src/Client.ts',
output: [
{
name: 'PocketBase',
file: 'dist/pocketbase.umd.js',
format: 'umd',
exports: 'default',
sourcemap: isProduction,
},
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
// CommonJS bundle (only the PocketBase client as default export).
{
input: 'src/Client.ts',
output: [
{
name: 'PocketBase',
file: 'dist/pocketbase.cjs.js',
format: 'cjs',
exports: 'default',
sourcemap: isProduction,
}
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
// !!!
// @deprecated - kept only for backwards compatibility and will be removed in v1.0.0
// !!!
//
// Browser-friendly iife bundle (only the PocketBase client as default export).
{
input: 'src/Client.ts',
output: [
{
name: 'PocketBase',
file: 'dist/pocketbase.iife.js',
format: 'iife',
sourcemap: isProduction,
},
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
];