maptiler / maptiler-sdk-js

Maps SDK tailored for MapTiler Cloud powered by MapLibre GL JS
https://docs.maptiler.com/sdk-js/
BSD 3-Clause "New" or "Revised" License
71 stars 14 forks source link

Does Map Tiler use Inflight? #94

Closed marksteven closed 2 months ago

marksteven commented 2 months ago

Have begun playing around with Svelte 5 pre release and got things working well until I add MapTiler/sdk. Project starts most of the time Locally fine but on build I get an error regarding inflight@1.0.6?? Removing Maptiler fixes the warnings so can maybe assume inflight is buried in there somewhere that I cannot find. Has anyone else had this issue with inflight@1.0.6 particularly as there is a warning on NPM saying it has a memory leak ?

jonathanlurie commented 2 months ago

Hello @marksteven , thanks for pointing at this issue! The SDK does not directly depends on inflight, but from the package-lock.json, I can see that glob depends on it, and a few dependencies depend on glob:

From a quick lookup, I could see that more recent versions of @rollup/plugin-commonjs and eslint no longer depend on inflight along the line.

I will update this and will try to make it part of the next release.

jonathanlurie commented 2 months ago

Hello again @marksteven , the fix is done on the main branch and we'll try to make a release soon, but we have other features/fixes we'd like to add too.

jonathanlurie commented 2 months ago

Part of v2.2.0 🎉 https://www.npmjs.com/package/@maptiler/sdk/v/2.2.0

marksteven commented 2 months ago

HI Jonathan thank you for that. I am still having issues so assuming maybe I now have the Svelte end set up wrong on the page ( I am using it as a Component imported into a page then use <Maptiler /> As there are no new docs yet, any chance you can post the example page of a Svelte Map that worked for you so I can see where I am going wrong. Of maybe I am a bit too soon and you have not pushed everything as yet? Currently for me with new SDK the map will often load, then on reload will then fail. <!-- <MapTiler /> --> Turning off Maptiler the page will load again fine. Turn back on. Then on reload fail again.

bolollo commented 2 months ago

Hi, @marksteven. You have a tutorial on how to use the SDK with Svelte here: https://docs.maptiler.com/svelte/. I have tested it with Svelte 4, and it works. I'm going to try Svelte 5 to see if it gives problems.

bolollo commented 2 months ago

Hi, @marksteven. I have tried Svelte 5 on a simple page with a map, and it has not given me any errors when building. For the build, I used the adapter-static. The only thing is that I had to change the onMount for an effect

$effect(() => {
 const initialState = { lng: 139.753, lat: 35.6844, zoom: 14 };

 map = new Map({
 container: mapContainer,
 style: MapStyle.STREETS,
 center: [initialState.lng, initialState.lat],
 zoom: initialState.zoom
 });
 });

I will also wait for version 5 to be released to update the documentation.

marksteven commented 2 months ago

Thanks for that. I'll give it a go and see what I get. And yes waiting probably good idea for the moment. Thanks

marksteven commented 2 months ago

Hi Bolo, Think I may have found one error at least and a fix. Svelte 5 the map loads fine under Dev, but if I try to Build it fails. So then if I then do exactly as you have stated using adapter-static plus the +layout.js with "export const prerender = true;" I can get it to work along with your $effect adjustment, so thankyou for that little Gem.

If I go back to the Cloudflare adapter rather than the static (as it fails if I use static -adapter on Cloudflare) but maintain the export const prerender = true; It will then work as well. so for the moment I have a work around so thank you. And hopefully this helps others for a work around till svelte 5 in finalised.