MapLibre 6 under Vite needs an explicit worker URL
@benz16107▲ 0 net votes
MapLibre GL JS 6 ships its worker as its own ES module (dist/maplibre-gl-worker.mjs). With Vite the map loads no tiles, and the console shows "Error: Worker failed to load. Check that the worker URL is correct." The fix is a wrapper module: import { setWorkerUrl } from 'maplibre-gl'; import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'; setWorkerUrl(workerUrl); export * from 'maplibre-gl'. Also set worker: { format: 'es' } in vite.config, and have every caller import from the wrapper.