-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsup.config.ts
52 lines (48 loc) · 1.2 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
import { spawn } from 'child_process'
import { defineConfig } from 'tsup'
import pkg from './package.json'
export default defineConfig(({ watch }) => [
{
splitting: false,
sourcemap: false,
clean: true,
dts: true,
target: 'es2022',
format: ['esm', 'cjs'],
entryPoints: ['src/exports/package.ts'],
shims: true,
},
{
splitting: false,
sourcemap: false,
clean: true,
dts: false,
target: 'es2022',
format: ['esm'],
entryPoints: ['src/exports/cli.ts'],
define: {
__VERSION__: `'${pkg.version}'`,
},
onSuccess: async () => {
if (watch) {
console.log('Build successful. Running playground...')
return new Promise((resolve, reject) => {
const child = spawn('pnpm', ['playground'], { stdio: 'inherit', shell: true })
child.on('close', (code) => {
if (code === 0) {
console.log('Playground script completed successfully.')
resolve()
} else {
console.error(`Playground script exited with code ${code}`)
reject(new Error(`Playground script exited with code ${code}`))
}
})
child.on('error', (error) => {
console.error('Failed to start playground script:', error)
reject(error)
})
})
}
},
},
])