question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting Turf back on track

See original GitHub issue

The goal for Turf v3 was to create a system in which Turf could be coordinated as a set of modules, operating independently but uniform in style, management, and properly versioned together. Unfortunately, that’s no longer the case: the current codebase is heterogenous, hard to contribute to, and the guidelines for releases are nonexistent.

About half of the modules are in TypeScript, and about half of those modules have a tsconfig.json file. About 40% of modules name their main export main, and the rest call it index. Same with providing a module entry point, it’s about 50%. 3 modules have a .mjs module file, the rest have .es.js.

Basically, there are no real homogenous properties of Turf anymore. It’s a worst-case scenario for a mono-repo: it makes Turf maintenance feel much more like β€˜maintaining 55 modules’ than it does β€˜maintaining a mono-repo’.

Turf modules summary
name tsconfig main module in ts
turf turf turf.mjs πŸ‘
along πŸ‘ index πŸ‘
angle πŸ‘ index πŸ‘
area πŸ‘ index πŸ‘
bbox πŸ‘ index πŸ‘
bbox-clip πŸ‘ index πŸ‘
bbox-polygon πŸ‘ index πŸ‘
bearing πŸ‘ index πŸ‘
bezier-spline πŸ‘ index πŸ‘
boolean-clockwise πŸ‘ index πŸ‘
boolean-concave πŸ‘ index πŸ‘
boolean-contains πŸ‘ index πŸ‘
boolean-crosses index πŸ‘
boolean-disjoint πŸ‘ index πŸ‘
boolean-equal index πŸ‘
boolean-intersects πŸ‘ index πŸ‘
boolean-overlap index πŸ‘
boolean-parallel index πŸ‘
boolean-point-in-polygon πŸ‘ index πŸ‘
boolean-point-on-line πŸ‘ index πŸ‘
boolean-touches index πŸ‘
boolean-valid index πŸ‘
boolean-within index πŸ‘
buffer main.js main.es.js
center index πŸ‘
center-mean index πŸ‘
center-median index πŸ‘
center-of-mass index πŸ‘
centroid index πŸ‘
circle index πŸ‘
clean-coords index πŸ‘
clone πŸ‘ index πŸ‘
clusters index πŸ‘
clusters-dbscan index πŸ‘
clusters-kmeans index πŸ‘
collect index πŸ‘
combine index πŸ‘
concave πŸ‘ index πŸ‘
convex πŸ‘ index πŸ‘
destination πŸ‘ index πŸ‘
difference index index.mjs
directional-mean πŸ‘ index πŸ‘
dissolve main.js main.es.js
distance index πŸ‘
distance-weight πŸ‘ index πŸ‘
ellipse main.js main.es.js
envelope main.js main.es.js
explode main.js main.es.js
flatten main.js main.es.js
flip main.js main.es.js
great-circle main.js main.es.js
helpers πŸ‘ index πŸ‘
hex-grid index πŸ‘
interpolate main.js main.es.js
intersect πŸ‘ index πŸ‘
invariant πŸ‘ index πŸ‘
isobands main.js main.es.js
isolines main.js main.es.js
kinks πŸ‘ index πŸ‘
length πŸ‘ index πŸ‘
line-arc πŸ‘ index πŸ‘
line-chunk main.js main.es.js
line-intersect πŸ‘ index πŸ‘
line-offset main.js main.es.js
line-overlap index πŸ‘
line-segment πŸ‘ index πŸ‘
line-slice main.js main.es.js
line-slice-along main.js main.es.js
line-split main.js main.es.js
line-to-polygon index πŸ‘
mask main.js main.es.js
meta index index.mjs
midpoint main.js main.es.js
moran-index πŸ‘ index πŸ‘
nearest-neighbor-analysis πŸ‘ index πŸ‘
nearest-point πŸ‘ index πŸ‘
nearest-point-on-line index πŸ‘
nearest-point-to-line πŸ‘ index πŸ‘
planepoint main.js main.es.js
point-grid index πŸ‘
point-on-feature main.js main.es.js
point-to-line-distance πŸ‘ index πŸ‘
points-within-polygon main.js main.es.js
polygon-smooth main.js main.es.js
polygon-tangents main.js main.es.js
polygon-to-line πŸ‘ index πŸ‘
polygonize main.js main.es.js
projection index πŸ‘
quadrat-analysis πŸ‘ index πŸ‘
random πŸ‘ index πŸ‘
rectangle-grid index πŸ‘
rewind main.js main.es.js
rhumb-bearing πŸ‘ index πŸ‘
rhumb-destination πŸ‘ index πŸ‘
rhumb-distance πŸ‘ index πŸ‘
sample main.js main.es.js
sector main.js main.es.js
shortest-path main.js main.es.js
simplify main.js main.es.js
square main.js main.es.js
square-grid πŸ‘ index πŸ‘
standard-deviational-ellipse main.js main.es.js
tag main.js main.es.js
tesselate main.js main.es.js
tin πŸ‘ index πŸ‘
transform-rotate main.js main.es.js
transform-scale main.js main.es.js
transform-translate main.js main.es.js
triangle-grid index πŸ‘
truncate index πŸ‘
union index πŸ‘
unkink-polygon main.js main.es.js
voronoi main.js main.es.js

Organizationally, Turf currently has a small chunk of cash, a much much smaller number of long-term maintainers, and zero institutional/company code contributors. This is pretty common for open source projects.

To propose a few ways forward:

Remove TypeScript

The TypeScript transition, while a very nice contribution, is unfinished and offers little to the project. We didn’t have many bugs caused by type mismatches before, and the resulting addition of complexity outweighs the benefit.

Would this be unpopular? Probably! But it’d be better to re-achieve stability and releasability, and make the project fit its actual contributors, than to perpetually be in a half-deployable state.

If this is the option, we could do it by basically configuring tsc to generate ES modules.

Move lerna.js back to fixed/locked mode

Per https://github.com/Turfjs/turf/pull/1247 the lerna config was switched to independent versioning. This makes collaboration harder: the intent of lerna was and is to make versioning automatic so that the project can be released always with lerna publish. There should not be a thought process for which modules need updating and releases.

Move releases/ back into changelog

This releases directory is the same as a central changelog. Let’s move these back to the changelog.

Use standard commits

Again, a common collaboration point - this will automate changelog generation and version more accurately

Write these contribution tips into CONTRIBUTING.md

And probably create a strong process for changing them. This stuff shouldn’t become wobbly; Turf should stay in a deployable, simple state that all the maintainers have a grasp on.

(Extreme solution) just move to a singular ES6 module

This would probably be even less popular than removing TypeScript: create one turf module (again), now that tree-shaking means that people using Rollup/Webpack/Parcel can efficiently import a subsection of a module without including all of the code. This would drastically reduce complexity and let advanced users continue to get the performance advantages of the current mini-modules, but it would leave people using old-fashioned require etc out in the cold.

Honestly I’m also in favor of this extreme solution: it’d be a huge decrease in complexity, and it’d do this for existing users:

  1. Script-tag or browserify users: yep, would be slower
  2. Node users: probably don’t mind the startup time or install size that much
  3. Webpack/Rollup users: would work great
  4. Future native-js module users: would easily be able to sub-import

This is intended to be a bit of a jumping-off point, none of these ways to victory are quick-fixes and we’d want to attain some consensus before embarking on them. Dividing this work up would also be useful, given that there are few maintainers, or if there is an institutional/company contributor who wants to take on some of this, it’d be more than welcome - Turf is definitely generating a lot of value out there in the world, much more than it captures.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:34 (14 by maintainers)

github_iconTop GitHub Comments

9reactions
rowanwinscommented, Jun 25, 2018

Hi @tmcw

Thanks for taking the time to check in on the status of the project, this has certainly been weighing on my mind over the past couple of months.

That said I want to start by saying the following

  • TurfJS has existed for the past few years largely on the back of the spare time, goodwill and interest of 3 people. This is important to recognise and thank - they’ve put in a huge effort and moved Turf forward a long way so thank you to my co-contributors @DenisCarriere & @stebogit πŸ™
  • Its worth remembering that in reality there are very few open source geospatial libs out there, and the bulk that exist piggyback on JTS, it’s a great reminder that we’re doing something that is complicated. We’ve also been doing it as volunteers in a JS world that is changing at great pace.

Re Typescript I’d be supportive of ditching the typescript-first approach

  1. We only have/had one active maintainer (out of the 3 at the time the decision was made) who knew anything about Typescript
  2. The Typescript definitions we’re using aren’t compatible with what other common mapping libraries are using which kind of seems to defeat the purpose IMHO.
  3. I can’t think of any instances where I’ve had to provide support around people using incorrect geometry types for operations.
  4. The previous approach allowed us to ship TS typings for those that were interested in using them but didn’t make TurfJS all in on TS.

On a personal & professional note I have no desire or need to learn TypeScript, TurfJS would be my sole reason for learning it.

Re Lerna

  1. Yep I think moving back to fixed versioning makes sense, this was working well in my opinion (eg the past few years until early this year).
  2. The other note about lerna & publishing is that for the past few years it’s always sat in the hands of one person, this obviously left a bit of a knowledge gap for the rest of the contributors. Lerna is it’s own beast and while I’ve published many libraries via npm attempting to go through the process with Turf with lerna was/is scary for a first-timer for fear of breaking things

Contributing.md Yeah agreed this is in dire need of an overhaul. Over the past 18 months there have been quite a number of changes to the various processes that have never been adequately captured.

Re All-in on ES6 So if I understand this correctly this would basically

  1. do away with the need for lerna; and
  2. npm would only contain a single turf package

Could you elaborate on use case 1 (β€˜Script-tag or browserify users’) - is that basically folks using Turf via a CDN? Why would that be slower under this proposal?

I think I cautiously support this approach. The bulk of browser apps (at least serious ones) are being built with some sort of bundling tool so I dont think we’d be leaving many out in the cold with this decision. My one proviso is that I think it would be nice to have some sort of basic bundled version (eg a CDN version) for people to hack with and learn with that doesn’t require them to get into the whole world of bundlers, it wouldn’t be the preferred method of usage but would be there to provide a low barrier of entry.

Anyway those are my initial thoughts - will ponder further and see if there is anything else that comes to mind.

Cheers Rowan

5reactions
rowanwinscommented, Jul 30, 2021

Thankfully after a few years hiatus Turf is back on track with a team of contributors helping on many fronts πŸŽ‰ We’ve now had a series of stables releases from v6.2.0 onwards. Still a lot of work to be done but lots of good progress is being made.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix Sunken Synthetic Turf - Trassig
Cut through the turf surface and pull the newly cut edges back to make a hole over the problem area. Β· Mix the...
Read more >
How to Get Turf to Stand Up Tall When They're Flat
Use a broom, stiff brush, or power broom (depending upon what tools you have) across your artificial turf surface to get the turf...
Read more >
Bringing your lawn back to life after the drought - Experts Nutrite
To get your lawn back on its feet after a lack of water, you'll first need a good watering for a few hours....
Read more >
Ask JW : Preventing Wrinkles In Turf
When your synthetic turf is tightly secured it is important to follow SGW Infill amounts and specifications for each product that you install....
Read more >
Getting Back on Track - The Pump Station (Turf's Up Radio ...
Listen LIVE weekdays 9am-10am EST on Turf's Up Radio. Listen online at turfsupradio.com or download the Turf's Up Radio app from your app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found