forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
193 lines (191 loc) · 5.74 KB
/
Copy pathtsdown.config.ts
File metadata and controls
193 lines (191 loc) · 5.74 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import { defineConfig } from "tsdown";
import path from "path";
// Resolved path to src/v2/context.ts — used to redirect the headless build's
// relative ../context imports to the external @copilotkit/react-core/v2/context
// package path, ensuring a shared React context instance at runtime.
const contextModulePath = path.resolve(import.meta.dirname, "src/v2/context");
export default defineConfig([
{
entry: ["src/index.tsx", "src/v2/index.ts"],
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
target: "es2022",
outDir: "dist",
external: [
"react",
"react-dom",
"@copilotkit/core",
"@copilotkit/shared",
"@copilotkit/web-inspector",
"@copilotkit/a2ui-renderer",
"rxjs",
/\.css$/,
],
exports: {
customExports: (exports) => ({
...exports,
"./v2/context": {
import: "./dist/v2/context.mjs",
require: "./dist/v2/context.cjs",
},
"./v2/headless": {
import: "./dist/v2/headless.mjs",
require: "./dist/v2/headless.cjs",
},
"./v2/styles.css": "./dist/v2/index.css",
}),
},
},
// v2/context is built separately into dist/v2/ so it produces a standalone
// file instead of being absorbed into shared chunks.
{
entry: {
context: "src/v2/context.ts",
},
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
target: "es2022",
outDir: "dist/v2",
external: ["react", "@copilotkit/core", "@copilotkit/shared"],
},
// v2/headless: platform-agnostic hooks + CopilotKitCoreReact, used by
// @copilotkit/react-native. All @copilotkit/* deps are external — they
// contain no Node-only code that would break Metro. Keeping them external
// (rather than inlining) ensures the CopilotKitCoreReact class is the same
// nominal type as the one in v2/context, avoiding unsafe `as unknown as` casts.
{
entry: {
headless: "src/v2/headless.ts",
},
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
target: "es2022",
outDir: "dist/v2",
plugins: [
{
name: "externalize-context",
resolveId(source, importer) {
// When any file imports ../context or ./context, redirect to
// the external package path so the context singleton is shared.
if (importer && /context(\.ts)?$/.test(source)) {
const resolved = path.resolve(path.dirname(importer), source);
if (
resolved === contextModulePath ||
resolved === contextModulePath + ".ts"
) {
return {
id: "@copilotkit/react-core/v2/context",
external: true,
};
}
}
return null;
},
},
],
external: [
"react",
"@ag-ui/client",
"@ag-ui/core",
"@copilotkit/core",
"@copilotkit/shared",
"@copilotkit/react-core/v2/context",
"uuid",
"zod",
"rxjs",
],
},
{
entry: ["src/index.tsx"],
format: ["umd"],
globalName: "CopilotKitReactCore",
sourcemap: true,
target: "es2020",
outDir: "dist",
external: [
"react",
"react-dom",
"@copilotkit/core",
"@copilotkit/shared",
"@copilotkit/runtime-client-gql",
"@copilotkit/web-inspector",
"@copilotkit/a2ui-renderer",
"@ag-ui/client",
"zod",
/\.css$/,
],
codeSplitting: false,
outputOptions(options) {
options.entryFileNames = "[name].umd.js";
options.globals = {
react: "React",
"react-dom": "ReactDOM",
"react/jsx-runtime": "ReactJsxRuntime",
"@copilotkit/core": "CopilotKitCore",
"@copilotkit/shared": "CopilotKitShared",
"@copilotkit/runtime-client-gql": "CopilotKitRuntimeClientGQL",
"@copilotkit/web-inspector": "CopilotKitWebInspector",
"@copilotkit/a2ui-renderer": "CopilotKitA2UIRenderer",
"@ag-ui/client": "AgUIClient",
"react-markdown": "ReactMarkdown",
zod: "Zod",
};
return options;
},
},
{
entry: ["src/v2/index.ts"],
format: ["umd"],
globalName: "CopilotKitReactCoreV2",
sourcemap: true,
target: "es2020",
outDir: "dist/v2",
external: [
"react",
"react-dom",
"@copilotkit/core",
"@copilotkit/shared",
"@copilotkit/runtime-client-gql",
"@copilotkit/web-inspector",
"@copilotkit/a2ui-renderer",
"@ag-ui/client",
"@ag-ui/core",
"zod",
/\.css$/,
],
codeSplitting: false,
outputOptions(options) {
options.entryFileNames = "[name].umd.js";
options.globals = {
react: "React",
"react-dom": "ReactDOM",
"react/jsx-runtime": "ReactJsxRuntime",
"@copilotkit/core": "CopilotKitCore",
"@copilotkit/shared": "CopilotKitShared",
"@copilotkit/runtime-client-gql": "CopilotKitRuntimeClientGQL",
"@copilotkit/web-inspector": "CopilotKitWebInspector",
"@copilotkit/a2ui-renderer": "CopilotKitA2UIRenderer",
"@ag-ui/client": "AgUIClient",
"@ag-ui/core": "AgUICore",
"react-markdown": "ReactMarkdown",
zod: "Zod",
"tailwind-merge": "tailwindMerge",
"lucide-react": "lucideReact",
"@radix-ui/react-slot": "RadixReactSlot",
"class-variance-authority": "classVarianceAuthority",
clsx: "clsx",
"@radix-ui/react-tooltip": "RadixReactTooltip",
"@radix-ui/react-dropdown-menu": "RadixReactDropdownMenu",
"katex/dist/katex.min.css": "katexCss",
streamdown: "streamdown",
"@lit-labs/react": "LitLabsReact",
"use-stick-to-bottom": "useStickToBottom",
"ts-deepmerge": "tsDeepmerge",
};
return options;
},
},
]);