Skip to content

chore(deps): upgrade react-map-gl to 8 through its Mapbox entry - #445

Merged
sydevs-bot merged 9 commits into
mainfrom
chore/react-map-gl-8
Nov 19, 2026
Merged

sydevs-bot merged 9 commits into
mainfrom
chore/react-map-gl-8

Conversation

@sydevs-bot

Copy link
Copy Markdown
Contributor

Summary

This upgrades react-map-gl from 7.1.9 to 8.1.3, the current latest on npm, and imports it through react-map-gl/mapbox. mapbox-gl stays at 3.35.0. The map behaves the same as on main, with one intended difference: a map=false embed no longer downloads Mapbox GL. There is a CHANGELOG entry for that. The eager payload does not grow.

What changed and why it matters

  • Entry point and types. v8 has no root entry, so every import now uses react-map-gl/mapbox. Views still reach it only through FullInterface, and layer paint and layout stay in layers.ts. Type changes v8 brought:
    • GeoJSONSource now comes from mapbox-gl's own types.
    • The highlight source's single feature carries properties: {}.
    • The four highlight layers are typed SymbolLayerProps, because v8's LayerProps also admits a slot layer, which takes no zoom range.
    • The events source drops online classes, whose geometry is null. Mapbox's clustering skipped those features anyway.
  • language={locale}. This is now a typed prop, so a misspelt prop name fails tsc. Before, it rode in a spread that escaped the excess-property check.
  • mapbox-gl is loaded by the map's first render (loadMapLib in Mapbox/map-lib.ts).
    • v8 imports mapbox-gl from <Map>'s mount effect, after the whole interface commits. On a local production build that was 442–457 ms later than v7. With the loader, the download starts 0–9 ms after the interface chunk, the same as v7.
    • Nothing calls the loader at module scope, so a map=false embed no longer downloads and runs the ~510 KiB gz library. v7 did, through its module-scope import('mapbox-gl').
  • The strict WebGL check v7 ran is kept.
    • v7's <Map> ran mapboxgl.supported(props), which is the strict failIfMajorPerformanceCaveat check, before it built a map. v8 dropped that check.
    • Without it, a browser that reports a major performance caveat (for example a blocklisted GPU) would suddenly get a map where main keeps the spinner, and a browser with no WebGL would build half a map and log two errors. Not every software renderer reports the caveat: Chromium 153's SwiftShader passes the strict check, which is why the browser lane's map draws.
    • The loader now refuses such a GPU with v7's own error, so these visitors see exactly what main shows them. The cached promise has a no-op catch: react-map-gl only listens from its mount effect, and without the catch the host page's error handlers would see an unhandled rejection.
  • Hover popover. v8's <Popup> only applies a new anchor when offset changes with it. Each anchor already has its own offset, and a spec now pins that.
  • Comments and docs. Several comments relied on v7's module-scope import. They are corrected, keeping every ⚠ line and feat(widget): degrade to a compact card in a slot too small for the interface #161 reference. docs/rules/mapbox.md documents the loader and the strict check.
  • Host contract. No origin, CSP or Permissions-Policy row changes, so docs/embedding.md is unchanged. The CHANGELOG [Unreleased] entry covers map=false.

Verification

  • Base. Rebased onto origin/main at 775dcea (chore(contracts): re-sync copied contracts from SahajCloud #439), which includes chore(contracts): re-sync copied contracts from SahajCloud #434, chore(deps): update @hookform/resolvers to 7 and schema-dts to 2 #436, chore(deps): upgrade Sentry SDK and Vite plugin to 11.15.0 #437 and chore(deps): tailwind-variants 4.0.2 on its lite runtime #438. The rebase applied with no conflicts, pnpm-lock.yaml included. pnpm install --frozen-lockfile passes at the tip, and pnpm install --lockfile-only leaves the lockfile unchanged.

  • .claude/skills/pr-prep/check.sh --full: passes on the rebased head. That covers lint, typecheck, the unit lane (177 files, 2134 tests), build (assert:css, assert:maps, assert:classic) and size.

  • pnpm ladle:build: passes, with no source maps across 168 files.

  • pnpm check:wrangler: both Worker configs dry-run OK.

  • Size, eager graphs (gzip, measured / shipped / budget): identical to a build of origin/main at 775dcea. Standalone 333.5 / 334.7 / 336 KiB, embed 334.6 / 335.8 / 336, loader 2.8 / 3.3 / 3.6.

  • Size, lazy map graph (gzip, zlib default level, FullInterface + shared + responsive chunks): 83.10 → 83.07 KiB against origin/main at 775dcea. The shared chunk goes 70.98 → 70.95, FullInterface stays at 11.47, and the mapbox-gl chunk stays at 512.08 KiB.

  • Specs, each watched failing against the defect it guards:

    • Every popover anchor has a distinct offset.
    • mapLib={loadMapLib()} is on the map element.
    • language={locale}.
    • map-lib.test.ts:
      • nothing is fetched on import (failed with a module-scope call);
      • mapbox-gl is imported once per page;
      • the check is the strict one (failed with supported() in place of supported(true));
      • an unsupported GPU is refused (failed with no gate);
      • a refusal is never an unhandled rejection (failed without the catch).
    • attribution.test.ts: Map.tsx calls the loader only from the map element and never imports mapbox-gl itself. It failed against a module-scope prefetch and against a direct import.
  • Browser, production build (placeholder token, Mapbox hosts stubbed, Chromium/SwiftShader):

    • Normal GPU: the map renders with its controls and logo, and the curtain lifts.
    • Caveat GPU (emulated) and no WebGL: an empty #mapbox, the curtain stays, and one "Map is not supported by this browser" error is logged. Screenshots are pixel-identical to main's.
    • map=false: mapbox-gl is never requested. Main requests it.
  • Browser, Ladle dev server: the map renders, and the strict check also works through Vite's dev interop.

  • Browser, A/B against main (two independent passes, Ladle and production builds): identical results for:

    • camera framing, including the first command jumping, region and event framing with drawer padding, and reuse on reopen;
    • clustering and cluster expansion;
    • all six hover-popover anchors;
    • the attribution (top right) and wordmark (bottom right) corners;
    • geolocation success and failure;
    • the reveal timer, gestures, resizing and theme switching.

    On a map embed, the mapbox-gl request starts as early as on main (interleaved medians 295 vs 301 ms).

Not done / not verified

  • Mapbox-backed content. Real tiles, the two Studio styles, glyphs and the geocoder were not exercised: there is no Mapbox token here, and stub styles were used. Cluster count text was therefore not drawn.
  • Terrain and globe. No one checked whether the production styles enable terrain or globe projection. That is where v8.1's Proxy-transform rewrite, and onMoveEnd reporting sea-level zoom, could differ from v7.
  • Browser checks after the rebase. None of the browser checks above was re-run on the rebased head; they were run before the rebase onto 775dcea. The main commits it picked up (contract types, @hookform/resolvers 7, schema-dts 2, Sentry 11.15.0, tailwind-variants 4) touch none of the map files, and the unit lane, build and size gate pass on the rebased head.
  • A/B after the last change. The full A/B was not re-run after the strict-check commit. That change only runs before the map is constructed, and the normal-GPU path was re-checked in both a production build and Ladle.
  • Main's behaviour without full WebGL support. Main was not rebuilt for that check. Its behaviour comes from a review's recorded run on a main build, compared pixel for pixel.
  • Other paths not exercised:
    • the review:embed host pages;
    • a real touch device;
    • a mid-session locale switch;
    • cooperative gestures.

Follow-ups for the maintainer

  • Product decision on the strict check. Visitors whose browser reports a major performance caveat keep a permanent spinner with no message. That is the same on main and here. If they should get a map instead, delete the throw in refuseUnsupported and record it in the CHANGELOG. That was left out of this upgrade on purpose.
  • Lockfile. Against origin/main, pnpm-lock.yaml changes only here: react-map-gl 7.1.9 → 8.1.3, @vis.gl/react-mapbox and @vis.gl/react-maplibre 8.1.3 added, and the deprecated @types/mapbox-gl 3.5.0 stub removed. If main moves again before merge, rebase and re-run pnpm install rather than merging the lockfile by hand.
  • Merge order with chore: pay down audited tech debt across deps, data, bundle and CI #442. This branch conflicts with chore: pay down audited tech debt across deps, data, bundle and CI #442 in CHANGELOG.md and src/components/organisms/Mapbox/Map.tsx; chore: pay down audited tech debt across deps, data, bundle and CI #442 also edits the map (cluster expansion through the current padding, react-hooks/exhaustive-deps). Whichever lands second rebases and re-runs the gate.
  • React 19. @vis.gl/react-mapbox declares its react peer as >=16.3, so it does not block the React 19 upgrade.
  • Dependency Review. It will list the new transitive @vis.gl/* packages (MIT). The maplibre wrapper is installed but not bundled.
  • .claude/. No edit there was needed.

Interaction with the browser lane PR (#444)

The browser lane pins a known defect: on main, a map=false embed still downloads the 1.9 MB mapbox-gl chunk, and scenario d asserts that it does. This upgrade fixes the defect, because it starts that download only on the map's first render. I merged both branches in a scratch worktree and ran the lane. Scenario d fails with its own message ("the defect is fixed: assert toEqual([]) here"). The other 8 scenarios pass, and so do this branch's own specs.

Whichever of the two lands second must flip the assertion in tests/browser/embed.spec.ts ("still fetches the mapbox-gl chunk, a known defect" → "never fetches the mapbox-gl chunk", expect(chunks).toEqual([]) after waiting on rendered()). It must also rewrite docs/testing.md § "A known defect, pinned". With that edit the lane passed 9 of 9, and that describe block passed 20 of 20 under --repeat-each 10.

If a future Chromium starts flagging SwiftShader as a major performance caveat, the lane's full-map scenario goes red from this branch's strict check, not from a lane regression.


Generated by Claude Code

react-map-gl 8 has no root entry: every import moves to `react-map-gl/mapbox`,
the endpoint for mapbox-gl 3.5 and later. mapbox-gl stays at 3.35.0.

Its types are now mapbox-gl's own, which are stricter in three places:

- `GeoJSONSource` is no longer re-exported, so `Map.tsx` takes it from
  mapbox-gl as a type.
- A GeoJSON source's `data` must carry `properties` and a geometry. The
  highlight source gains `properties: {}`, and the events source drops the
  online classes, whose geometry is null. Mapbox skipped those features
  anyway, clustering included, so nothing drawn changes.
- `LayerProps` admits a `slot` layer, which takes no zoom range, so the
  highlight layers `PointSource` bounds by zoom are typed as the symbol
  layers they are (`SymbolLayerProps`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
react-map-gl 8 types `<Map>` with mapbox-gl's own `MapOptions`, which lists
`language`. The spread that carried it past the excess-property check is no
longer needed, so a misspelt prop name now fails `tsc`. The attribution spec
pins the plain prop instead: watched failing against `language={languageCode}`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
react-map-gl 8 moves its `import('mapbox-gl')` from module scope into
`<Map>`'s mount effect (`@vis.gl/react-mapbox`'s `components/map.js`), so
the comments resting on the module-scope fetch were wrong:

- An eager react-map-gl import costs its own code, which `pnpm size` counts:
  measured, one `useMap` import in `use-map-controller.tsx` put both graphs
  over budget by 2.1 and 3.2 KiB. The seam warnings keep their rule and say so.
- The node lane loads `use-mapbox.ts` now (probed with a throwaway spec), so
  `store.ts` says why the camera flag lives there rather than that it must.
- `MapFrame.test.tsx` still cannot render `FullInterface`: mounting the map
  fires the import.
- The map instance arrives once that import resolves, not a microtask after
  the mounting commit.

The lazy `FullInterface` boundary (#161) is unchanged, and the history of
what react-map-gl 7 cost a compact embed stays, tagged with its version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
react-map-gl 8's `<Popup>` applies a new `anchor` only inside the branch for
a changed `offset` (`@vis.gl/react-mapbox`'s `components/popup.js`); 7 applied
it on its own. The pin popover stays mounted while the pointer crosses from
one pin to the next, so two anchors sharing an offset would leave the second
card on the first pin's side. `pinPopoverPlacement` gives each of its six
anchors a distinct offset today; this pins that. Watched failing with the
horizontal offset forced to 0 (2 distinct offsets for 6 anchors).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
react-map-gl 8 imports mapbox-gl from `<Map>`'s mount effect, which waits for
the whole interface to commit. Measured on a production build served locally
(4 loads each), the library's request started 3-4ms after the lazy interface
chunk under react-map-gl 7 and 442-457ms after it under 8, and the library is
the map's long pole.

`Map.tsx` now hands react-map-gl the import as `mapLib`, started by the map's
first render through a memoised loader: 0-9ms after the chunk again. The
loader stays out of module scope, so a `map=false` embed, which imports
`Map.tsx` through `FullInterface` but renders no map, no longer downloads
the library, which react-map-gl 7 fetched there too.

The attribution spec pins both halves: watched failing with the prop
dropped, and with the import moved to module scope. The comments describing
where mapbox-gl is fetched now say `mapLib`, and CHANGELOG records the
`map=false` change; no origin, CSP or Permissions-Policy change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
react-map-gl 7's <Map> ran mapboxgl.supported(props) before it constructed
the map. With a props object that is the strict check
(failIfMajorPerformanceCaveat). react-map-gl 8 dropped it. So a browser whose
WebGL runs in software, or on a blocklisted GPU, drew a map where main keeps
the curtain. A browser with no WebGL at all built half a map in #mapbox and
logged two errors instead of one.

The loader moves to map-lib.ts and refuses such a GPU with v7's own error,
which react-map-gl logs from its mount effect. That effect can run after the
import settles, so the cached promise carries a no-op catch. Without it the
rejection would reach the host page's error handlers.

map-lib.test.ts pins the loader: nothing is fetched on import, mapbox-gl is
imported once per page, the check is the strict one, and a refusal is never
an unhandled rejection. attribution.test.ts now also fails when Map.tsx calls
the loader anywhere but the map element. Its old pattern let a module-scope
prefetch through, and that brings back the map=false download.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
attribution.test.ts said importing Map.tsx would pull mapbox-gl into the node
lane. Under react-map-gl 8 it does not. The spec reads the source because
mapbox reads those literals only when it constructs a map, which needs WebGL.

store.ts kept its warning on where the camera-settled flag lives, but its
reason had become version history saying the reason was gone. It now says
why the flag still belongs in the eager store: use-mapbox.ts imports
react-map-gl, so an eager reader there would pull it into every embed.

The CHANGELOG entry said the old build never ran Mapbox GL on a map=false
embed. A dynamic import evaluates what it fetches, so it did run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
#445

mapbox-gl's supported(true) asks WebGL with failIfMajorPerformanceCaveat, and
Chromium 153 grants that on SwiftShader, so the check does not refuse software
rendering in general. Reword the claims to a browser that reports a major
performance caveat, such as a blocklisted GPU driver, and give the CHANGELOG
entry its PR reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 031bc8b Nov 19 2026, 11:17 PM

@sydevs-bot
sydevs-bot enabled auto-merge November 19, 2026 23:23
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 19, 2026
@sydevs-bot

sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
Merged via the queue into main with commit 09aee18 Nov 19, 2026
17 checks passed
@sydevs-bot
sydevs-bot deleted the chore/react-map-gl-8 branch November 19, 2026 23:27
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 19, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 19, 2026
…t-a11y

CHANGELOG.md conflicted twice, both additive: main's #445 entry and this
branch's two #432 entries landed in the same `### Changed` position, and
their link definitions in the same place at the foot. Both sides kept,
ordered by descending PR number like the entries around them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjUuV5HDHKkDZZVCxFe
sydevs-bot pushed a commit that referenced this pull request Nov 19, 2026
Three hunks, all kept from both sides.

CHANGELOG keeps #445's `map=false` entry and this branch's 44 KiB entry,
and both link definitions.

Map.tsx keeps #445's `loadMapLib` import, `GeoFeature` and `hasPoint`
alongside this branch's `mapWorldview`. The `MAP_WORLDVIEWS` table that
`main` still holds in Map.tsx is dropped there and kept in
`map-language.ts`, where this branch moved it and corrected the Japanese
key from `jp` to `ja`.

`Map.click.test.tsx` imported and mocked `react-map-gl`, which #445
removed as an entry point when it upgraded to react-map-gl 8. Both now
name `react-map-gl/mapbox`, the specifier `Map.tsx` already uses.

Lean gate green on the merged tree, with the build and `pnpm size`:
lint, typecheck, 180 spec files (2271 passed, 1 skipped). The eager
payload is unchanged at 290.6 / 291.7 / 3.3 KiB shipped.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjUujhd78iBhzSNLwcL
sydevs-bot pushed a commit that referenced this pull request Nov 20, 2026
Three resolutions:

- `src/views/shared.tsx` — keep both. #435's `role="search"` landmark on the
  wrapper, and this branch's controlled `value`/`onChange` on `MapSearch`, which
  is what stops half-typed text reaching `?q`.
- `scripts/check-bundle-size.mjs` — both sides raised the embed budget to 338
  from 336, so the figure stands and both history entries stay. Re-measured on
  the merge: standalone 335.5, embed 336.6, so 337.0 and 337.8 shipped, inside
  338 with 0.2 KiB spare on the embed.
- The five specs mocking `react-map-gl` now mock `react-map-gl/mapbox`. #445
  upgraded the library to 8, which publishes no root entry, so every one of them
  died at import.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX8sHLcAAW89cXoi6P
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants