[Maps][Vega] Tidy up mapbox-gl imports#99733
Conversation
| import mbWorkerUrl from '!!file-loader!mapbox-gl/dist/mapbox-gl-csp-worker'; | ||
|
|
||
| mapboxgl.workerUrl = mbWorkerUrl; | ||
| mapboxgl.setRTLTextPlugin(mbRtlPlugin); |
There was a problem hiding this comment.
@thomasneirynck can you give me more info about this worker? Why are we adding this? Sorry, I don't have a lot of experience with mapbox :D
There was a problem hiding this comment.
hi @stratoula, this bring vegamaps in line with how mapbox maps are instantiated in Maps (
)These workers are spawned by mapbox-gl.
This PR changes Vegamaps, so it constructs mapbox with a static-worker script (pointing explicitly to mbWorkerUrl), iso. an inlined string which is the default way mapbox instantiates its workers.
The latter approach was hitting on some possible violations of Kibana's CSP. See #51675.
Apart from that, construction is now the same between Maps and Vega, so it would also give us a pathway to extract mapbox-gl into a separate bundle, reducing footprint.
|
Pinging @elastic/kibana-gis (Team:Geo) |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Unknown metric groupsmiscellaneous assets size
References to deprecated APIs
History
To update your PR or re-run it, just comment with: |
stratoula
left a comment
There was a problem hiding this comment.
Thank you Thomas, LGTM!
VegaMaps now instantiates mapbox-gl the same way as the Maps app.
This PR tidies up some of the mapbox-gl import inconsistencies between Maps and Vega
This should make the mapbox-gl -> maplibre-gl switch more clean, restricting it to the imports and the yarn.lock change.
Open questions: as suggested here #85566 (comment), we can also isolate mapbox-gl loading in single plugin, further improving the use of the library. this will also reduce total kibana bundle size, since it won't get packaged with two plugins. (although, the dependency is lazy-loaded, it would only affect total kibana size, not necessarily kibana startup time).