Turf: How to reduce bundle size?

Created on 9 Mar 2020  路  2Comments  路  Source: Turfjs/turf

Hello there,
this is my webpack bundle analyzer report, and as you see, the turf size is pretty big (556ko)!

image

I've verified twice, and all my files contains only partial imports, like this:

import {
  getCoords,
  nearestPoint,
  along,
  point
} from "@turf/turf";

So I don't understand why this is so big?

Am I doing something wrong?

Thanks!

Most helpful comment

For now the @turf/turf dependency isn't set up for proper tree shaking (I'd like to fix that). In the meantime, I've had success shrinking my total bundle size by using the sub packages @turf/nearest-point and similar.

All 2 comments

Can you confirm which modules you're importing @maximelebreton - there are some which will result in large bundles although the ones above shouldn't be particuarly problematic.

And which version of turfjs do you have in your package-lock.json?

For now the @turf/turf dependency isn't set up for proper tree shaking (I'd like to fix that). In the meantime, I've had success shrinking my total bundle size by using the sub packages @turf/nearest-point and similar.

Was this page helpful?
0 / 5 - 0 ratings