Repository navigation
fix(react-core): make maplibre-gl opt-in so apps build without it - #8346
Merged
Merged
Conversation
The standard Map loaded its optional peer with import("maplibre-gl") in
the /generative-ui entry. Bundlers resolve that specifier at build time,
so a Next app (webpack or Turbopack) that imported standardUI without
maplibre-gl failed with "Can't resolve 'maplibre-gl'".
The import now lives only in a new /generative-ui/map entry, like the
Angular and Vue opt-ins. Apps pass its loader in the generativeUI
config: generativeUI={{ ui: standardUI, map: loadMapLibre }}. Without
it, Map renders its list of places from the first render, on the server
too.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 1
Please check the settings in the CodeRabbit UI or the
|
Contributor
Production Digest-Pinning AuditAll 44 services digest-pinned. Run 2026-11-12 04:32:10 PST — 0 finding(s). |
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/intelligence-langgraph
@copilotkit/intelligence-mastra
@copilotkit/learning
@copilotkit/markdown
@copilotkit/mcp-apps-renderer
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/runtime
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
Contributor
|
Size Change: +1.84 kB (+0.08%) Total Size: 2.43 MB 📦 View Changed
ℹ️ View Unchanged
|
Merged
4 tasks done
Write the loader ref with useLatestRef, not during render, so React Doctor's no-ref-current-in-render check passes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tional # Conflicts: # showcase/shell-docs/src/content/docs/generative-ui/components/from-a2ui.mdx # showcase/shell-docs/src/content/docs/generative-ui/components/standard-catalog.mdx # showcase/shell-docs/src/content/reference/components/CopilotKit.mdx
… standardUI
`generativeUI` now takes `ui` as optional. Without it, the provider uses
`standardUI` when the runtime turns generative UI on, and keeps the other
options, so `generativeUI={{ map: loadMapLibre }}` turns the map on for the
runtime's standard UI.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An app that imports
standardUIfrom@copilotkit/react-core/generative-uiand does not installmaplibre-glfails to build. Next with webpack or Turbopack stops withModule not found: Can't resolve 'maplibre-gl', andnext devreturns 500. This PR moves the onlyimport("maplibre-gl")into a new opt-in entry,@copilotkit/react-core/generative-ui/map, like the Angular and Vue opt-ins. Without the opt-in,Mapshows its list of places, as the docs promise.What does this PR do?
/generative-ui/mapentry. It exportsloadMapLibreand is the only module that importsmaplibre-gl.map?: GenerativeUILibraryLoaderto thegenerativeUIconfig.Mapreads it. Without a loader,Maprenders the list from the first render, on the server too, so hydration matches.exports,typesVersions, the tsdown entry, the public API manifest, andtsconfig.docs.json.CopilotKitreference) and opts thea2ui-markdowndemo in (it addsmaplibre-glto that demo).uioptional ingenerativeUI. Since feat!: make generative UI the only client path and serve A2UI v0.9 agents from every runtime #8348, the provider falls back tostandardUIwhen the runtime turns generative UI on.generativeUI={{ map: loadMapLibre }}now keeps the map loader for that fallback, so an app that relies on the fallback can still turn the map on.Related PRs and Issues
Checklist
!(for examplefeat(react-core)!: ...) and the description has aBREAKING CHANGE:line with migration steps. See VERSIONING.mdTesting
Commands run
nx run-many -t build test check-types -p @copilotkit/react-core: pass (196 test files).@copilotkit/markdown:check-typesfailed once and passed on the Nx retry. It races its ownbuild, and this PR does not touch it.pnpm lint: OK after building the packages that the type-aware rules need. The baseline entry forMap.tsxis removed because the hit is gone.oxfmt --check,commitlint,pnpm check:public-api-manifest,scripts/__tests__/validate-types-versions.test.ts,nx run repo-scripts:check-docs-snippets: pass.nx run @copilotkit/example-a2ui-markdown:example-build: pass (needs a dummyOPENAI_API_KEY).Scratch apps outside the repo, with packed tarballs and no
maplibre-glinstalled2.0.0-rc.41(before)next build --webpackCan't resolve 'maplibre-gl'next build --turbopackCan't resolve 'maplibre-gl'next dev,GET /mapvite buildand devIn a browser (Playwright,
next start), the/mappage renders aMapsurface:maplibre-gl:data-a2ui-map="fallback", the list shows Vienna and Graz, no page errors.[email protected]andmap: loadMapLibre:data-a2ui-map="ready", one MapLibre canvas, two pins. The Next webpack, Next Turbopack, and Vite builds all pass. Vite putsmaplibre-glin its own chunk.Vite did not fail before this PR, because it leaves an unresolved dynamic import to fail at runtime. It still works after.
Manual test
@copilotkit/[email protected]. Do not installmaplibre-gl.generativeUI={{ ui: standardUI }}toCopilotKitProviderin a client component. Runnext build. It fails withCan't resolve 'maplibre-gl'.pnpm packinpackages/react-coreand its workspace deps). Runnext buildagain. It passes.maplibre-gl, addmap: loadMapLibrefrom@copilotkit/react-core/generative-ui/map, and ask the agent for a map. The map draws.How this PR makes testing easy
standard/__tests__/map.test.tsx: the list without a loader (server render too), a real map throughloadMapLibrewith a fakemaplibre-gl, a pin click that writes the bound path, and the failure paths (rejected loader, wrong module, no WebGL, inline loader on each render).__tests__/maplibre-imports.test.ts: fails if any source file other thangenerative-ui/map.tsimportsmaplibre-glagain.a2ui-markdownexample opts in, so its Vienna coffee-house prompt still draws a map.Risk / rollback
An app that installs
maplibre-gland does not opt in now gets the list instead of a map. Addmap: loadMapLibreto keep the map. This only affects the 2.0 RC line, where the component is experimental. To undo, revert this PR.Public API change
Before
After
🤖 Generated with Claude Code