-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtsup.config.ts
More file actions
76 lines (75 loc) · 2.32 KB
/
tsup.config.ts
File metadata and controls
76 lines (75 loc) · 2.32 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
import { defineConfig } from 'tsup'
import path from 'path'
export default defineConfig({
entry: {
index: 'src/exports/index.ts',
providers: 'src/exports/providers.ts',
types: 'src/exports/types.ts',
components: 'src/exports/components.ts',
workspace: 'src/exports/workspace.ts',
},
format: ['esm', 'cjs'],
dts: true,
splitting: true,
sourcemap: true,
clean: true,
tsconfig: 'tsconfig.lib.json',
treeshake: true,
external: [
'react', 'react-dom', 'next',
// Database drivers — consumers install what they need
'pg', 'mysql2', 'better-sqlite3', 'oracledb', 'mssql', 'mongodb', 'ioredis',
// SSH and crypto
'ssh2',
// Monaco editor
'monaco-editor', '@monaco-editor/react',
// LLM SDKs
'@google/generative-ai',
// UI libs that consumers provide
'elkjs', 'recharts',
'framer-motion', 'html2canvas',
'@tanstack/react-table', '@tanstack/react-virtual',
'react-resizable-panels', 'react-hook-form', '@hookform/resolvers',
'react-day-picker', 'embla-carousel-react', 'input-otp',
'sonner', 'vaul', 'cmdk', 'next-themes',
// Radix primitives
/^@radix-ui\//,
// Utilities
'class-variance-authority', 'clsx', 'tailwind-merge',
'sql-formatter', 'date-fns', 'zod', 'yaml', 'jose', 'openid-client',
'lucide-react',
],
esbuildPlugins: [
{
name: 'resolve-at-alias',
setup(build) {
// Rewrite @/ → ./ and let esbuild resolve from src/
build.onResolve({ filter: /^@\// }, async (args) => {
return build.resolve('./' + args.path.slice(2), {
resolveDir: path.resolve(__dirname, 'src'),
kind: args.kind,
})
})
},
},
{
name: 'handle-css-and-xyflow',
setup(build) {
// Replace CSS imports with empty modules.
// CSS is handled by the consumer's bundler (Next.js/Vite), not at runtime.
build.onResolve({ filter: /\.css$/ }, (args) => ({
path: args.path,
namespace: 'ignore-css',
}))
build.onLoad({ filter: /.*/, namespace: 'ignore-css' }, () => ({
contents: '',
}))
// Mark @xyflow/react (non-CSS) as external
build.onResolve({ filter: /^@xyflow\/react$/ }, () => ({
path: '@xyflow/react',
external: true,
}))
},
},
],
})