watergis / maplibre-gl-terradraw

This plugin is to add controls to your maplibre for sketching powered by terradraw library.
https://terradraw.water-gis.com/
MIT License
16 stars 1 forks source link

Peer Dependencies? #10

Closed neodescis closed 1 month ago

neodescis commented 1 month ago

Hello! I just saw the MapLibre example that uses this library. I'm excited to see this, and I'm going to look into using it in my own application. However, I'm looking at the dependencies in package.json, and I'm wondering, shouldn't maplibre-gl and terra-draw be listed as peer dependencies instead of regular dependencies?

neodescis commented 1 month ago

I'm also wondering if it wouldn't be better to list the versions as >= to avoid having to wait for this library to update its dependency versions?

JinIgarashi commented 1 month ago

@neodescis Thank you for mentioning this. Actually terra-draw is bundled to the plugin itself. it should be moved to devDependencies. I think maplibre-gl can be moved to peerDependencies as you suggested.

neodescis commented 1 month ago

Hmm, does that mean if I install this library, but then want to add something to the terra-draw instance it creates in my own app (and thus need to import something from terra-draw itself), my app would end up with two copies of terra-draw in its bundle? That seems like something to be avoided.

JinIgarashi commented 1 month ago

I see. Here, maplibre-gl is excluded. maybe terra-draw needs to be included here.

https://github.com/watergis/maplibre-gl-terradraw/blob/b3a8a063bfe557c8d0b7c42d1c8def325a5740ae/vite.lib.config.ts#L17-L24

JinIgarashi commented 1 month ago

@neodescis I just did test locally whether I can exclude terra-draw from bundled js. but it has a problem of using umd module through CDN. to support CDN, terra-draw needs to be bundled inside the plugin itself.

But I will move both maplibre-gl and terra-draw to peerDependencies.

JinIgarashi commented 1 month ago

@neodescis I fixed package.json and released as 0.0.4

neodescis commented 1 month ago

Thank you!