-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtsup.config.ts
More file actions
50 lines (49 loc) · 1.26 KB
/
tsup.config.ts
File metadata and controls
50 lines (49 loc) · 1.26 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
import { defineConfig } from "tsup";
export default defineConfig([
// Library build - fully bundled for easy consumption
{
entry: ["src/index.ts"],
format: ["esm"],
dts: true,
sourcemap: true,
clean: true,
outDir: "dist",
bundle: true, // Bundle all dependencies
splitting: false,
treeshake: true,
external: [], // Bundle everything - no external deps
esbuildOptions(options) {
options.platform = "node";
options.target = "node20";
},
},
// CLI build - fully bundled single file
{
entry: {
"cli/index": "src/cli/index.ts",
},
format: ["esm"],
dts: false,
sourcemap: false,
clean: false, // Don't clean - library already did
outDir: "dist",
bundle: true, // Fully bundle CLI into single file
minify: true,
splitting: false,
treeshake: true,
external: [], // Bundle everything
esbuildOptions(options) {
options.platform = "node";
options.target = "node20";
},
async onSuccess() {
const { chmodSync, readFileSync, writeFileSync } = await import("node:fs");
const cliPath = "dist/cli/index.js";
const content = readFileSync(cliPath, "utf-8");
if (!content.startsWith("#!/usr/bin/env node")) {
writeFileSync(cliPath, `#!/usr/bin/env node\n${content}`);
}
chmodSync(cliPath, 0o755);
},
},
]);