Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tahini opened this issue Nov 5, 2024 · 2 comments
Open

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

tahini opened this issue Nov 5, 2024 · 2 comments

Comments

@tahini
Copy link
Collaborator

tahini commented Nov 5, 2024

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

  • See if latest version of @turf/turf better supports tree shaking and avoids bundling everything
  • See if it's possible to bypass the linter error and simply import sub-packages directly in our code, while still having our package.json files depend on @turf/turf
  • Last resort is to go back to individually depending on packages in package.json, but we need to absolutely make sure the package versions are the same everywhere to avoid bundling many versions of the same packages.
@greenscientist
Copy link
Collaborator

Can we quantize the benefits of going individual stuff?

@tahini
Copy link
Collaborator Author

tahini commented Nov 6, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants