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:
- Script-tag or browserify users: yep, would be slower
- Node users: probably don't mind the startup time or install size that much
- Webpack/Rollup users: would work great
- 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.
typescript