-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtsup.config.ts
More file actions
94 lines (90 loc) · 2.99 KB
/
tsup.config.ts
File metadata and controls
94 lines (90 loc) · 2.99 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
import { defineConfig } from 'tsup'
import { build as esbuildBuild } from 'esbuild'
import { copyFileSync, cpSync, existsSync, mkdirSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
const WEBFETCH_EXTERNALS = [
'@mozilla/readability',
'ipaddr.js',
'jsdom',
'robots-parser',
'turndown',
'undici',
]
async function bundleWebServerForDist(webServerDist: string, outputDir: string): Promise<void> {
const entryFile = join(webServerDist, 'main.js')
if (!existsSync(entryFile)) {
console.warn('! web-server main.js not found, skipped bundling dist/web/server/main.cjs')
return
}
mkdirSync(outputDir, { recursive: true })
await esbuildBuild({
entryPoints: [entryFile],
outfile: join(outputDir, 'main.cjs'),
bundle: true,
minify: false,
sourcemap: false,
platform: 'node',
format: 'cjs',
target: 'node22',
legalComments: 'none',
external: [
'@dqbd/tiktoken',
'class-transformer',
'class-validator',
'@nestjs/websockets',
'@nestjs/websockets/socket-module',
'@nestjs/microservices',
'@nestjs/microservices/microservices-module',
...WEBFETCH_EXTERNALS,
],
})
writeFileSync(
join(outputDir, 'package.json'),
`${JSON.stringify({ type: 'commonjs' }, null, 2)}\n`,
'utf8',
)
}
export default defineConfig({
entry: {
index: 'packages/tui/src/cli.tsx',
},
outDir: 'dist',
format: ['esm'],
target: 'node22',
dts: false,
clean: true,
minify: true,
sourcemap: false,
splitting: false,
bundle: true,
external: WEBFETCH_EXTERNALS,
esbuildOptions(options) {
options.jsx = 'automatic'
},
banner: {
js: '#!/usr/bin/env node',
},
async onSuccess() {
// Copy prompt.md to dist directory
copyFileSync(join('packages/core/src/runtime/prompt.md'), join('dist/prompt.md'))
mkdirSync(join('dist/task-prompts'), { recursive: true })
cpSync(join('packages/tui/src/task-prompts'), join('dist/task-prompts'), {
recursive: true,
})
const webServerDist = join('packages/web-server/dist')
if (existsSync(webServerDist)) {
const bundledServerDist = join('dist/web/server')
mkdirSync(join('dist/web'), { recursive: true })
await bundleWebServerForDist(webServerDist, bundledServerDist)
}
const webUiDist = join('packages/web-ui/dist')
if (existsSync(webUiDist)) {
mkdirSync(join('dist/web'), { recursive: true })
cpSync(webUiDist, join('dist/web/ui'), { recursive: true })
console.log('✓ Copied prompt.md, task prompts, and web server/ui assets to dist/')
return
}
console.log('✓ Copied prompt.md and task prompts to dist/')
console.warn('! web-ui dist not found, skipped copying dist/web/ui')
},
})