Skip to content

Fix VectorTileSource in SvelteKit builds#349

Merged
awesomephant merged 22 commits intomainfrom
fix-348
Apr 7, 2026
Merged

Fix VectorTileSource in SvelteKit builds#349
awesomephant merged 22 commits intomainfrom
fix-348

Conversation

@awesomephant
Copy link
Copy Markdown
Collaborator

@awesomephant awesomephant commented Apr 4, 2026

The problem was caused by a race condition between VectorTileSource and VectorLayer. For some unknown reason, VectorLayer is mounted first in production builds independent of source order (not in dev), which causes it to break because its source doesn't exist yet.

We fix that by nesting VectorLayer inside VectorSource, which makes the mounting order deterministic (other projects take the same approach):

<VectorTileSource>
  <VectorLayer>
  </VectorLayer>
</VectorTileSource>

This PR:

  • Adds a waitForStyleLoaded() method to MapContext to queue source/layers in the correct order
  • Updates documentation and stories for VectorTileSource and VectorLayer
  • Cleans up some related files in the maplibre directory
  • Adds e2e testing for this issue and similar dev/build differences in the future
  • Downcases workflow titles for style
fix(maplibre): VectorTileSource/VectorLayer race condition (#349)

Closes #348

@awesomephant awesomephant marked this pull request as ready for review April 5, 2026 13:48
@awesomephant awesomephant merged commit 23a380a into main Apr 7, 2026
3 checks passed
@awesomephant awesomephant deleted the fix-348 branch April 7, 2026 16:48
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.

VectorTileSource doesnt work in built SvelteKit app

1 participant