Files
David McKay 0a582df4dd fix(react-native): add /headless subpath so custom-UI consumers skip chat/attachment native deps
The `@copilotkit/react-native` barrel statically re-exports the prebuilt chat
UI (CopilotChat / CopilotModal / CopilotSidebar / CopilotPopup, which import
`@gorhom/bottom-sheet`) and `useAttachments` (which imports
`expo-document-picker` + `expo-file-system`). Those are optional peer deps, but
a static re-export still forces Metro to resolve them at bundle time. A headless
consumer that uses only `CopilotKitProvider` + `useAgent` + `useFrontendTool`
(a fully custom UI) had to install every chat/attachment native dep or stub them
in `metro.config.js`, or the release bundle fails with
`Unable to resolve module expo-document-picker`.

Add a lean `@copilotkit/react-native/headless` entry that re-exports only the
provider, the platform-agnostic hooks, the render-tool registry, and the
core/AG-UI types — none of the chat UI or `useAttachments` — so those native
deps never enter the bundle graph and the metro-stub workaround is retired.

Mirrors `@copilotkit/react-core/v2/headless` (#5883): a standalone entry file,
wired into the tsdown entry list, the package.json `exports` map, and
`sideEffects` (it side-effect-imports the polyfills). The default barrel now
does `export * from "./headless"` and layers the chat UI on top, so it stays
fully backward compatible. Adds a static import-graph regression test asserting
the headless graph never reaches the chat/attachment modules or their native
peer deps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 14:56:43 -07:00

37 lines
822 B
TypeScript

import { defineConfig } from "tsdown";
export default defineConfig({
entry: [
"src/index.ts",
"src/headless.ts",
"src/components/index.ts",
"src/polyfills.ts",
"src/polyfills/streams.ts",
"src/polyfills/encoding.ts",
"src/polyfills/crypto.ts",
"src/polyfills/dom.ts",
"src/polyfills/location.ts",
],
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
target: "es2022",
outDir: "dist",
external: [
"react",
"react-native",
"@ag-ui/client",
"@copilotkit/react-core",
"@copilotkit/core",
"@copilotkit/shared",
"@ag-ui/client",
"@gorhom/bottom-sheet",
"react-native-streamdown",
"react-native-gesture-handler",
"react-native-reanimated",
"react-native-enriched-markdown",
"react-native-worklets",
"remend",
],
});