-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
64 lines (51 loc) · 1.28 KB
/
tsup.config.ts
File metadata and controls
64 lines (51 loc) · 1.28 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
import { defineConfig } from 'tsup'
export default defineConfig([
// Node.js 版本(完整功能:Server + Client)
{
entry: ['src/index.ts'],
format: ['esm'],
dts: true,
clean: true,
shims: false,
minify: true,
sourcemap: false,
// 打包策略:external 运行时依赖
external: ['@grpc/grpc-js', '@grpc/proto-loader', 'ws'],
// 输出配置
outDir: 'dist',
// 保留注释(包含 JSDoc)
keepNames: true,
// 兼容性
target: 'es2022',
platform: 'node',
// 移除 console.log(生产环境启用)
esbuildOptions(options) {
options.drop = ['console']
},
},
// 浏览器版本(只包含 Client)
{
entry: {
browser: 'src/browser-entry.ts'
},
format: ['esm'],
dts: true,
shims: false,
minify: true,
sourcemap: false,
// 浏览器环境:external 所有 Node.js 依赖和内置模块
external: ['@grpc/grpc-js', '@grpc/proto-loader', 'ws', 'path', 'fs'],
noExternal: [],
// 输出配置
outDir: 'dist',
// 保留注释
keepNames: true,
// 兼容性
target: 'es2020',
platform: 'browser',
// 移除 console.log(生产环境启用)
esbuildOptions(options) {
options.drop = ['console']
},
}
])