-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtsup.config.ts
51 lines (45 loc) · 1.13 KB
/
tsup.config.ts
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
import { Options, defineConfig } from 'tsup';
const sharedConfig: Options = {
bundle: true,
splitting: true,
sourcemap: true,
treeshake: true,
minify: false,
clean: true,
keepNames: true,
env: {
SERVER_ACCESS_CONTROL_MAX_AGE: '',
},
noExternal: ['@zimic/utils'],
};
const neutralConfig = (['cjs', 'esm'] as const).map<Options>((format) => ({
...sharedConfig,
name: `neutral-${format}`,
platform: 'neutral',
format: [format],
dts: format === 'cjs' ? { resolve: true } : false,
entry: {
index: 'src/index.ts',
http: 'src/http/index.ts',
},
external: ['util', 'buffer', 'crypto'],
}));
const nodeConfig = (['cjs', 'esm'] as const).map<Options>((format) => {
const entry = {
server: 'src/server/index.ts',
cli: 'src/cli/index.ts',
'scripts/postinstall': 'scripts/postinstall.ts',
};
const dtsEntry = {
server: entry.server,
};
return {
...sharedConfig,
name: `node-${format}`,
platform: 'node',
format: [format],
dts: format === 'cjs' ? { entry: dtsEntry, resolve: true } : false,
entry,
};
});
export default defineConfig([...neutralConfig, ...nodeConfig]);