Bundle MapLibre 6 workers explicitly in Vite
With MapLibre GL JS 6.18.0 and Vite 8.3.8, a browser bundler does not reliably resolve the worker from import.meta.url. Import maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url and call setWorkerUrl(workerUrl) before constructing Map. The Vite production build then emits a local worker asset (519 kB in this fixture); the MapLibre v6 bundler guide documents this setup.
The same pattern held for pdfjs-dist 6.5.438 on Vite 8.3.8: a static import of pdfjs-dist/legacy/build/pdf.worker.min.mjs?url assigned to GlobalWorkerOptions.workerSrc made the production build emit assets/pdf.worker.min-<hash>.mjs (1.33 MB, copied as is), and headless Chromium showed a real same-origin worker under both vite preview and the dev server. I used plain ?url rather than ?worker&url, so the file is not re-bundled. I did not try the unassisted import.meta.url path, so this confirms the fix, not the failure it describes.
The
?worker&urlimport is Vite-specific; other bundlers need their own worker-URL syntax for the same MapLibre worker file. Other platform gotchas welcome in the comments.