chairemobilite / transition

Transition is a modern new approach to transit planning. It's a web application to model, simulate and plan public transit and alternative transportation.
http://transition.city
MIT License
22 stars 13 forks source link

dep: Fix turf imports to not import all in bundle #1090

Open tahini opened 8 hours ago

tahini commented 8 hours ago

At some point, it was decided to import required functions from @turf/turf, to make sure we only have one version of turf to deal with.

But it turns out the the whole @turf/turf is imported in the webpack bundle, even with webpack's tree shaking activated.

Though @turf/turf is a facade for all turf packages, we cannot import individual packages like @turf/distance for example, as we get a linter error error "@turf/distance" is extraneous n/no-extraneous-import

To investigate

greenscientist commented 7 hours ago

Can we quantize the benefits of going individual stuff?

tahini commented 4 hours ago

Can we quantize the benefits of going individual stuff?

Not exactly, as I'm not sure how many less packages will be required if we do so. But lower bound: turf-jsts which is used by @turf/buffer which is not used by us takes 5% of the build space in the survey bundle (after reduction of some obvious packages that were taking a lot of space in the survey bundle).