-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
144 lines (136 loc) · 4.43 KB
/
tsup.config.ts
File metadata and controls
144 lines (136 loc) · 4.43 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import { defineConfig } from "tsup";
// everything that ships as a peer dep or is only needed at
// the consumer's build time goes here — never bundle these.
const sharedExternal = [
"react",
"react-dom",
"react/jsx-runtime",
// all radix primitives
/^@radix-ui\/.*/,
// cmdk, tailwind, lucide — large, always present in consumer projects
"cmdk",
"tailwindcss",
"tailwindcss/plugin",
"lucide-react",
// class helpers — tiny but user may tree-shake their own copy
"clsx",
"tailwind-merge",
"class-variance-authority",
// tiptap — all packages are peer deps, never bundle them
/^@tiptap\/.*/,
"lowlight",
// react-hook-form — optional peer dep, never bundle it
"react-hook-form",
// veloria-ui itself — the rhf and motion entries import from it
"veloria-ui",
];
const cliExternal = [
...sharedExternal,
"chalk",
"commander",
"execa",
"fs-extra",
"ora",
"prompts",
];
export default defineConfig([
// ── Main component library ──────────────────────────────────────────────
{
entry: { index: "src/index.ts" },
format: ["cjs", "esm"],
dts: true,
splitting: true,
sourcemap: true,
clean: true,
treeshake: true,
external: sharedExternal,
outDir: "dist",
banner: {
js: `/**
* veloria-ui
* Build anything. Ship faster.
* By JohnDev19 — https://github.com/JohnDev19/Veloria-UI
* MIT License
*/`,
},
},
// ── RHF adapter ─────────────────────────────────────────────────────────
{
entry: { rhf: "src/rhf/index.ts" },
format: ["cjs", "esm"],
dts: true,
splitting: false,
sourcemap: true,
clean: false,
treeshake: true,
external: sharedExternal,
outDir: "dist",
},
// ── Motion system ────────────────────────────────────────────────────────
//
// veloria-ui/motion — zero-dependency animation layer built on the
// Web Animations API. No Framer Motion, no GSAP.
//
// Separate entry so tree-shaking removes it entirely from projects
// that don't import it. Keeps "use client" isolated.
{
entry: { motion: "src/motion/index.ts" },
format: ["cjs", "esm"],
dts: true,
splitting: false,
sourcemap: true,
clean: false,
treeshake: true,
external: sharedExternal,
outDir: "dist",
banner: {
js: `/**
* veloria-ui/motion
* Web Animations API motion layer — zero dependencies.
* By JohnDev19 — MIT License
*/`,
},
},
// ── VeloriaProvider ──────────────────────────────────────────────────────
{
entry: { provider: "src/provider.tsx" },
format: ["cjs", "esm"],
dts: true,
sourcemap: true,
clean: false,
external: sharedExternal,
outDir: "dist",
},
// ── Tailwind plugin ──────────────────────────────────────────────────────
{
entry: { tailwind: "src/tailwind.ts" },
format: ["cjs"],
dts: true,
sourcemap: false,
clean: false,
external: ["tailwindcss", "tailwindcss/plugin"],
outDir: "dist",
},
// ── CLI binary ───────────────────────────────────────────────────────────
//
// IMPORTANT — shebang handling:
//
// Do NOT use banner: { js: "#!/usr/bin/env node" } here.
// tsup's banner is appended after its own generated file header,
// which puts the shebang on line 2+. Node.js requires the shebang
// to be the very first bytes of the file (byte 0).
//
// Correct approach: add the shebang as a postbuild step that prepends
// it directly to dist/cli/index.js before publishing.
{
entry: { "cli/index": "src/cli/index.ts" },
format: ["cjs"],
dts: false,
splitting: false,
sourcemap: false,
clean: false,
treeshake: true,
external: cliExternal,
outDir: "dist",
},
]);