Emit and register the maplibre worker as a build asset - #277
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 astext/html, and the module worker died ⇒ blank map for every authenticated user.Fix:
?worker&urlimport (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