diff --git a/lib/layer/format/maplibre.mjs b/lib/layer/format/maplibre.mjs index 7fb268095..2a15f9281 100644 --- a/lib/layer/format/maplibre.mjs +++ b/lib/layer/format/maplibre.mjs @@ -23,6 +23,15 @@ async function MaplibreGL() { maplibregl = imports[0] + // Avoid loading RTL Text Plugin twice, else it will error + if (!["deferred", "loaded"].includes(maplibregl.getRTLTextPluginStatus())) { + maplibregl.setRTLTextPlugin( + 'https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.min.js', + null, + true // Lazy load the plugin + ); + } + resolve() }) .catch(error => { @@ -34,14 +43,6 @@ async function MaplibreGL() { await promise - // Avoid loading RTL Text Plugin twice, else it will error - if (!["deferred", "loaded"].includes(maplibregl.getRTLTextPluginStatus())) { - maplibregl.setRTLTextPlugin( - 'https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.min.js', - null, - true // Lazy load the plugin - ); - } return new maplibregl.Map(...arguments); }