Skip to content

Emit and register the maplibre worker as a build asset - #277

Merged
yorickdewid merged 1 commit into
mainfrom
fix/maplibre-worker-asset
Jul 25, 2026
Merged

Emit and register the maplibre worker as a build asset#277
yorickdewid merged 1 commit into
mainfrom
fix/maplibre-worker-asset

Conversation

@yorickdewid

Copy link
Copy Markdown
Contributor

The actual root cause of the blank map since #273: maplibre v6 resolves its worker as a sibling module at runtime (new URL('./maplibre-gl-worker.mjs', import.meta.url)), which the bundler can't statically see — the file was never emitted, the request fell through to the SPA catch-all as text/html, and the module worker died ⇒ blank map for every authenticated user.

Fix: ?worker&url import (Vite bundles worker + deps, hashed URL) + setWorkerUrl(). Verified end-to-end locally with a headless probe of the 404-page map (the only unauthenticated route that mounts a map): worker served as JS, map renders.

Reproduced on prod first: GET /assets/maplibre-gl-worker.mjs → 200 text/html.

🤖 Generated with Claude Code

maplibre v6 loads its worker as a sibling module via a runtime-computed
URL - invisible to the bundler, so the file was never emitted. At runtime
the request for /assets/maplibre-gl-worker.mjs fell through to the SPA
catch-all (text/html), the module worker died and the map stayed blank.
This never showed in CI or unauthenticated probes because the map only
mounts behind login (and on the 404 page).

?worker&url bundles the worker with its imports and returns the hashed
URL, registered via setWorkerUrl(). Worker output names get the same
per-build suffix as the main bundle.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yorickdewid
yorickdewid merged commit cc32ced into main Jul 25, 2026
4 checks passed
@yorickdewid
yorickdewid deleted the fix/maplibre-worker-asset branch July 25, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant