Skip to content

[BUG] maplibre-gl v6 map embeds render blank on PR preview deploys #468

Description

@lowlydba

Branch deploy for #465 (the maplibre-gl 5→6 bump) has a blank map: staging.overturemaps.org/docs/pr/465-no-autogen/guides/buildings shows nothing past the background fill, vs. the working live buildings guide.

Root cause

maplibre-gl v6 ships ESM-only. Per the v5→v6 migration guide, bundler consumers must call setWorkerUrl() explicitly, since import.meta.url no longer resolves the worker chunk from inside a bundle.

The worker file (maplibre-gl-worker.mjs) also statically imports a sibling chunk, maplibre-gl-shared.mjs. Rspack's asset handling for new URL('maplibre-gl/dist/maplibre-gl-worker.mjs', import.meta.url) only emits the referenced file, not that sibling, so maplibre-gl-shared.mjs 404s. It 404s silently too: the dev server's SPA fallback serves index.html for the missing path with a text/html content type instead of a real 404, so there's nothing in the console to point at. The worker's module import then fails with an opaque error, the map never fires load/idle, and nothing past the background layer paints.

On top of that, our CI uses lowlydba/sustainable-npm with ignore-scripts defaulting to true as of v3.0.0, which skips npm's automatic pre/post lifecycle hooks (prestart/prebuild) while still running whatever's explicitly invoked by npm run. A first attempt at the fix relied on a prebuild hook to copy the worker files, so it worked locally but stayed broken on the actual staging PR preview.

Fix

See #467.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions