Repository navigation
Expand file tree
/
Copy pathtsup.config.ts
More file actions
138 lines (137 loc) · 4.45 KB
/
Copy pathtsup.config.ts
File metadata and controls
138 lines (137 loc) · 4.45 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
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",
security: "src/exports/security.ts",
},
format: ["esm", "cjs"],
dts: true,
splitting: true,
sourcemap: true,
clean: true,
tsconfig: "tsconfig.lib.json",
treeshake: true,
// Keep `node:`-prefixed builtin imports intact: tsup strips the prefix by
// default (import("node:sqlite") -> import("sqlite")), which breaks
// node:sqlite — that builtin exists only WITH the prefix. The package
// targets Node >= 24 + modern bundlers, which all understand `node:`.
removeNodeProtocol: false,
external: [
"react",
"react-dom",
"next",
// Database drivers — consumers install what they need
"pg",
"mysql2",
"better-sqlite3",
"bun:sqlite", // Bun-runtime builtin (SQLite DB provider driver under Bun)
"node:sqlite", // Node-runtime builtin (SQLite DB provider driver under Node)
"oracledb",
"mssql",
// The DuckDB driver ends in a native `require('.../duckdb.node')`; both the
// API package and its binding loader stay external so nothing resolves an
// addon into the published ESM/CJS bundles.
"@duckdb/node-api",
"@duckdb/node-bindings",
// The Db2 driver's loader ends in a native `require('./db2-node.<triple>.node')`.
"db2-node",
// Pure JS, but external for the same reason it is in `serverExternalPackages`:
// its optional `require('kerberos')` is unresolvable at build time.
"cassandra-driver",
"mongodb",
"ioredis",
"@platformatic/kafka",
// The etcd provider's gRPC client and the loader that reads its generated descriptor.
"@grpc/grpc-js",
"@grpc/proto-loader",
// The neo4j provider's Bolt driver; consumers install it like the other drivers.
"neo4j-driver-lite",
"@libredb/libredb",
// 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",
// Exact-pinned image-capture engine (html-to-image variants choke on
// Tailwind 4 computed styles); external like every other UI lib - it is
// a regular dependency, so consumers resolve it via npm.
"@zumer/snapdom",
// The Graph tab's canvas and layout, loaded by a dynamic import in
// cytoscape-host.ts; both are regular dependencies, exact-pinned.
"cytoscape",
"cytoscape-fcose",
// The S3 object preview's Parquet reader, loaded by a dynamic import in preview-parquet.ts; ESM only, resolved by the host.
"hyparquet",
"hyparquet-compressors",
"@tanstack/react-table",
"@tanstack/react-virtual",
"react-resizable-panels",
"react-hook-form",
"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",
// The Spark provider's Arrow decoder: a regular dependency, exact-pinned; external so a consumer resolves the one
// copy its lockfile holds.
"apache-arrow",
],
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,
}));
},
},
],
});