Uh oh!
There was an error while loading. Please reload this page.
feat(maplibre)!: require MapLibre GL JS v6 - #866
Conversation
MapLibre v6 dropped its UMD and CSP bundles, so the pinned unpkg script tag no longer resolves. The registry entry now runs in npm mode and imports the `maplibre-gl` package, matching how PostHog loads. - Peer dependency: `^5.24.0` -> `^6.0.0` - Registry `src` is `false`; the bundle capability is removed - Stylesheet comes from `maplibre-gl/dist/maplibre-gl.css`, so the pinned CDN URL and its integrity hash are gone - The worker URL is set from `maplibre-gl-worker.mjs?worker&url`, which MapLibre requires under any bundler. `workerUrl` still overrides it. Closes#857
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (12)
Included review availability: Your plan includes up to 4 reviews per rolling hour; 0 remain after this review. 📝 WalkthroughWalkthroughMapLibre integration now uses the MapLibre v6 ESM package instead of CDN scripts. The runtime loads the package, injects its stylesheet when enabled, configures bundled or custom workers through Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk:⚪ Minimal · up to This PR updates MapLibre loading, worker, stylesheet, and dependency handling for v6, with the supplied checks and playground verification passing. No actionable merge-blocking risk remains beyond normal review and checks. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Uh oh!
There was an error while loading. Please reload this page.
🔗 Linked issue
Supersedes #857.
📚 Description
MapLibre v6 is ESM-only.
dist/maplibre-gl.jsanddist/maplibre-gl-csp.jsare no longer published, so the pinned unpkg script tag 404s and nothing setswindow.maplibregl.bundle: truecan't work either: the ESM entry imports sibling chunks the bundle downloader never fetches. #857 on its own would have shipped a dead map.The registry entry now runs in
scriptMode: 'npm'and importsmaplibre-gl, same shape as PostHog. The stylesheet comes from the package too, which kills the second pinned CDN URL and its integrity constant.stylesheetUrlstill injects a custom link.The worker took a while to track down. v6 builds the worker URL at runtime from
import.meta.urlrather than a staticnew URL()literal, so no bundler can rewrite it:The map got as far as fetching the style and sprites, then sat there with a hidden canvas because
loadnever fired. MapLibre's install guide says every bundler consumer needs a one-timesetWorkerUrl(), and?worker&urlrather than plain?url, because the worker imports its siblingmaplibre-gl-shared.mjs. Production now emits_nuxt/maplibre-gl-worker-<hash>.js.Component code needed nothing. The v6 breaks we could have hit are all APIs we don't touch:
styleimagemissingbecoming notify-only, themap.transformremoval,GeoJSONSource.setDatalosing its second argument.<ScriptMapLibreMap>needmaplibre-gl@^6. It was already a documented install for types.Loose end:
?worker&urlis Vite syntax and I only exercised the Vite builder. Not sure what rspack/webpack do with it. Might want a builder check or at least a docs note.