-
Notifications
You must be signed in to change notification settings - Fork 3
/
tsup.config.ts
64 lines (63 loc) · 1.26 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
52
53
54
55
56
57
58
59
60
61
62
63
64
import { readFile, writeFile } from 'fs/promises';
import { defineConfig } from 'tsup';
export default defineConfig([
{
entry: ['src/index.ts'],
format: ['esm'],
dts: true,
sourcemap: false,
clean: true,
platform: 'browser',
target: 'es2022',
},
{
entry: ['src/index.ts'],
format: ['esm'],
dts: false,
sourcemap: false,
clean: true,
platform: 'browser',
target: 'es2022',
minify: 'terser',
outDir: 'dist/min',
},
{
entry: ['src/modern.ts'],
format: ['esm'],
dts: true,
sourcemap: false,
clean: true,
platform: 'browser',
target: 'es2022',
outDir: 'dist/modern',
},
{
entry: ['src/modern.ts'],
format: ['esm'],
dts: false,
sourcemap: false,
clean: false,
platform: 'browser',
target: 'es2022',
minify: 'terser',
outDir: 'dist/modern/min',
},
{
entry: ['src/legacy.cts'],
format: ['cjs', 'esm'],
outExtension(ctx) {
return { js: ctx.format === 'cjs' ? '.cjs' : '.mjs' };
},
dts: true,
sourcemap: false,
clean: true,
platform: 'neutral',
target: 'es5',
minify: false,
outDir: 'dist/legacy',
onSuccess: async () => {
const file = await readFile('dist/legacy/legacy.mjs', 'utf-8');
await writeFile('dist/legacy/legacy.mjs', file.replace(/module\.exports = (.+);/, ''));
},
},
]);