fix: react-maplibre - support maplibre-gl v6 - #2598
Conversation
…ansformCameraUpdate, event typing)
|
Does the package have a setup to test each version separately? |
No.. CI only tests against whatever version is pinned in package.json (bumped to ^6.0.0 here). The v4/v5 fallback path is manually verified via type-checks, not an automated test.. that's been the case for this repo generally, not specific to this PR. Could open a follow-up for a version matrix if that's wanted. |
Thanks
Personally I think this would be a good addition given that we start working around version specifics. But maybe lets wait for a signal from the maintainers. |
I could be open to it, though I'd like input from @Pessimistress since she's thought a lot about version compatibility. And as @miketu926 mentioned - the type system is catching the majority of version compatibility issues. Overtime, we have had to drop support for older major versions when they diverge greatly - then we must document the last react-map-gl version with support for X basemap version. |
|
I traced the current CI failure and opened #2599 to move the repository CI/development runtime to Node.js 24.18.0. Once #2599 is merged, please rebase this PR onto master. That removes the jsonlint Node engine blocker, but two PR-local failures remain afterward:
I validated that Node 24 plus the gl-matrix 3.4.4 resolution builds successfully; yarn lint then reports only that formatting issue from this PR. |
Pessimistress
left a comment
There was a problem hiding this comment.
I suspect we may get more divergence as v6 development continues, and will eventually need a dedicated endpoint. But for now the changes seem manageable.
|
@Pessimistress updated MCs against latest |
|
Added CI test matrix |
|
Had to get a little create to bridge types that aren't available on older versions. Edit: We discussed it we'll relax the type safety to |
* fix(react-maplibre): support maplibre-gl v6 (transform getters, setTransformCameraUpdate, event typing) * clean up * clean up * code review * test(react-maplibre): cover public camera getters * fix(react-maplibre): bridge box zoom event types * fix: deduplicate gl-matrix dependency * chore: rely on deduplicated gl-matrix lockfile * test: configure MapLibre worker for browser tests * ci: test MapLibre v6 * fix(react-maplibre): bridge versioned MapLibre types * refactor(react-maplibre): simplify layer property setters --------- Co-authored-by: Chris Gervang <chris.gervang@joby.aero>
|
@miketu926 I'm getting following error when I use with my next.js@16 project. Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. http://localhost:3000/_next/static/media/maplibre-gl-shared.mjs |
Issue is unrelated to maplibre support. You'll need a /public route for that .mjs file |
|
Yes, I ran into similar issues upgrading our website and examples. From a user's pov, this feels like a regression and I hope they can improve it in the future.. We've added a note in our get started guide and the release notes about v6's new bundler setup requirements. Their installation snippets were helpful. Docusaurus, Webpack, and Vite users can see #2602 for how we upgraded this package. |
Fixes #2597.
Summary
Adds MapLibre GL JS v6 support to the
react-maplibrewrapper while preserving compatibility with v4 and v5. MapLibre v6 removed the publicmap.transformproperty and replaced directtransformCameraUpdateassignment withsetTransformCameraUpdate().Changes
map.transform.setTransformCameraUpdate()at runtime and falls back to the legacytransformCameraUpdateproperty on v4/v5.getCenterElevation()is unavailable on pre-v5 MapLibre.^4.0.0,^5.0.0, and^6.0.0in CI.Testing
LngLatidentity.map.transform.Note
Medium Risk
Changes core map camera sync and event wiring used on every map instance; mistakes could affect view state or handlers across v4–v6, though feature detection limits blast radius.
Overview
Adds maplibre-gl v6 support in the react-maplibre wrapper while keeping v4/v5 working. Dev dependency and CI matrix now include
^6.0.0; browser tests set the v6 worker URL when needed for Vite.Camera / view state: v6 drops public
map.transformand assigningtransformCameraUpdate. The wrapper usesgetTransformLike()(public getters) for view-state sync and resize checks (canvas.clientWidth/Height), and registers camera updates viasetTransformCameraUpdate()when present, otherwise the legacy property.Types / events:
MapBoxZoomEventis derived fromMapEventTypeafter the v6 rename;map.on()handlers are typed withkeyof MapEventType. Layer updates useas anyon layout/paint property keys to satisfy v6’s strictersetLayoutProperty/setPaintPropertytypes.Tests cover
getTransformLike(including pre-v5 elevation default).Reviewed by Cursor Bugbot for commit 732bbef. Bugbot is set up for automated code reviews on this repo. Configure here.