Migrate the demo pages to MapLibre GL JS v6 (ESM) - #53
Merged
Merged
Conversation
The demo map went blank on both golftiles.org and the GitHub Pages site without any commit causing it. index.html and docs/index.html loaded MapLibre from an unpinned URL, so unpkg resolved maplibre-gl to the new v6.4.0. v6 is ESM-only: it publishes maplibre-gl.mjs and no longer ships dist/maplibre-gl.js, so that script tag 404'd, the maplibregl global was never defined, and the first line of the demo script threw a ReferenceError before a map was ever constructed. MapLibre 6.0.0 was published 2026-07-22, which is when the demos silently broke. Move all three demo pages to v6 instead of pinning back to v5: import the namespace inside the existing module script, since v6 has no default export. pmtiles stays on 3.2.0 - its v3compat protocol wrapper already detects the AbortController signature and works unchanged under v6, which was verified rather than assumed. The CSS link is pinned to a major version too, since the unpinned CSS URL was the same latent hazard. demo/local-viewer.html was pinned to @5 and so was never broken, but it moves to v6 as well to keep the three demo pages on one version. Verified each page in headless Chrome over CDP: the worker loads cross-origin from the CDN via MapLibre's blob module shim, pmtiles range requests succeed, and the golf layers render with no console errors. Co-authored-by: HuggeK <48095810+HuggeK@users.noreply.github.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 demo map on both golftiles.org and huggek.github.io/golfTiles has been blank for about three and a half weeks. Nothing we committed caused it, and nothing we commit would have fixed it.
Both pages loaded MapLibre from an unpinned URL:
unpkg resolves that to
latest, and maplibre-gl 6.0.0 was published 2026-07-22. v6 is ESM-only — it shipsdist/maplibre-gl.mjsand no longer publishesdist/maplibre-gl.jsat all. So the script tag 404s, themaplibreglglobal is never defined, and the very first line of the demo script throwsReferenceError: maplibregl is not definedbefore a map is ever constructed. You get an empty<div id="map">and nothing in the UI to explain it.How this was confirmed
https://unpkg.com/maplibre-gl/dist/maplibre-gl.js→ 404. Probed every plausible bundle name —maplibre-gl.js,.umd.js,.min.js,.iife.js,.global.jsall 404; only.mjsand the CSS return 200.package.jsonhas nomain, nobrowser, nounpkgfield — onlymodule: dist/maplibre-gl.mjsand an ESM-onlyexportsmap.demo/local-viewer.htmlwas pinned to@5, which is exactly why it kept working.What this changes
All three demo pages move to v6 rather than pinning back to v5:
index.htmldocs/index.htmldemo/local-viewer.html@5, workingThe migration itself is small — v6 has no default export, so the namespace is imported inside the module script that was already there:
pmtiles stays on 3.2.0. Its
v3compatwrapper already detects theAbortControllersignature, so it works unchanged under v6 — verified, not assumed. Bumping it was unnecessary risk.The CSS link is now pinned too. It happened to survive, but it was the same latent hazard.
Why pin the major version rather than an exact one
@6matches the conventiondemo/local-viewer.htmlalready used (@5), and it is what the MapLibre migration guide suggests. It still lets patch and minor releases through, but a future v7 with another breaking change cannot silently take the demo down the way v6 just did. If you would rather freeze completely, changing@6to@6.4.0in three places is the whole edit.Verification
Driven in headless Chrome over the DevTools Protocol, loading each page as actually written — not a synthetic reproduction:
maplibre-gl.mjs,maplibre-gl-shared.mjsandmaplibre-gl-worker.mjsall load. The worker comes from the CDN cross-origin via MapLibre's blob module shim, so no self-hosting is needed.demo/local-viewer.htmlwas tested against a staged bundle (fixture tiles + style + viewer) over a Range-capable server, and renders Emmaboda Golfklubb fully — fairways, greens, bunkers, water, tee markers and labels.Two pre-existing issues found while testing — not touched here
Both are unrelated to this migration and are left for separate PRs:
tees_bordershas an invalid colour. v6 reports it precisely:layers[tees_borders].paint.line-color: Could not parse color from value 'yellow;red' Falling back to rgba(0,0,0,1).That looks like a raw OSM multi-value tag reaching the style. It renders black today.
No
glyphsproperty in the style, although there aresymbollayers usingtext-fieldwithtext-font: ["Open Sans Regular"]. It does not block loading — MapLibre falls back to rendering codepoints locally, which is why labels still appear — but there is no glyph server backing the configured font.