From e0bdd0add87f21a4430f8884736096d1ac6fe4cd Mon Sep 17 00:00:00 2001 From: James Beard Date: Tue, 12 Mar 2024 10:41:26 +1100 Subject: [PATCH] Converting packages to type: module by default (#2565) Updating Turf packags to be ESM modules rather than a CommonJS project. The build still generates and packages both ESM and CJS variants of implementation and types. From a client perspective, nothing should change about the way Turf modules are loaded or called. * Marking all packages as "ESM first", with additional CJS files for compatibility. Flow on changes from that include requiring a js extension for relative includes, and workarounds for a couple of older third party libraries that were no longer importing smoothly. Builds successfully. Updating tests next. * Adding js extension to more local imports in tests, and removing references to __dirname. Added some re-exporting wrapper files for older packages like rbush and sweepline-intersections. See turf-line-intersects for an example. * Disabling some type tests in packages we were having export / import issues in post type: module. Maybe someone in future can exercise some typescript jujitsu to re-enable them. * Reverting dist/ generated JS to .js extension where possible. Was identified that the .cjs extension was causing problems for some consumers. Would have like to use .d.ts rather .d.cts for CJS type defs, but there's a but in tsup at the moment that won't allow that to be customised. * Reintroducing __dirname references, though need to add implementation as not supplied automatically by node any more. Updating benchmark tests. Adding some missing bench and tape @types libraries. * Added a few __dirname references that should have been included, and removed a few that had inadvertently been added. * Explicitly using cjs extension for CommonJS distributed source files. Got disabled types tests working again by adjusting tsc command (needed to include node16 module and moduleResolution switched on command line). Also needed to refer to "index", etc as "index.js", etc from test.ts files to avoid "Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16'" errors. * Missed a .js -> .cjs in turf/turf last-checks target. * Removing hacky cjs/esm export/import wrappers in favour of defaultImport library which takes care of finding the correct default to import from CJS packages. * Revert "Removing hacky cjs/esm export/import wrappers in favour of defaultImport library which takes care of finding the correct default to import from CJS packages." This reverts commit f8184c3fb124369b36fb9afa4e1aa83543417e42. * Found a few more spots to add a js extension to satisfy newer node16 module resolution. --- .monorepolint.config.mjs | 41 +-- package.json | 4 +- packages/turf-along/bench.ts | 6 +- packages/turf-along/package.json | 12 +- packages/turf-along/test.ts | 5 +- packages/turf-angle/bench.ts | 2 +- packages/turf-angle/package.json | 12 +- packages/turf-angle/test.ts | 5 +- packages/turf-area/bench.ts | 5 +- packages/turf-area/package.json | 12 +- packages/turf-area/test.ts | 5 +- packages/turf-bbox-clip/bench.ts | 5 +- packages/turf-bbox-clip/index.ts | 2 +- packages/turf-bbox-clip/package.json | 12 +- packages/turf-bbox-clip/test.ts | 5 +- packages/turf-bbox-polygon/bench.ts | 2 +- packages/turf-bbox-polygon/package.json | 12 +- packages/turf-bbox-polygon/test.ts | 2 +- packages/turf-bbox/bench.ts | 2 +- packages/turf-bbox/package.json | 12 +- packages/turf-bbox/test.ts | 2 +- packages/turf-bearing/bench.ts | 2 +- packages/turf-bearing/package.json | 12 +- packages/turf-bearing/test.ts | 5 +- packages/turf-bezier-spline/bench.ts | 5 +- packages/turf-bezier-spline/index.ts | 2 +- packages/turf-bezier-spline/package.json | 12 +- packages/turf-bezier-spline/test.ts | 5 +- packages/turf-boolean-clockwise/bench.ts | 5 +- packages/turf-boolean-clockwise/package.json | 12 +- packages/turf-boolean-clockwise/test.ts | 5 +- packages/turf-boolean-concave/bench.ts | 5 +- packages/turf-boolean-concave/package.json | 12 +- packages/turf-boolean-concave/test.ts | 3 + packages/turf-boolean-contains/bench.ts | 5 +- packages/turf-boolean-contains/package.json | 12 +- packages/turf-boolean-contains/test.ts | 5 +- packages/turf-boolean-crosses/bench.ts | 5 +- packages/turf-boolean-crosses/package.json | 12 +- packages/turf-boolean-crosses/test.ts | 5 +- packages/turf-boolean-disjoint/bench.ts | 5 +- packages/turf-boolean-disjoint/package.json | 12 +- packages/turf-boolean-disjoint/test.ts | 5 +- packages/turf-boolean-equal/bench.ts | 5 +- packages/turf-boolean-equal/package.json | 12 +- packages/turf-boolean-equal/test.ts | 5 +- packages/turf-boolean-intersects/bench.ts | 5 +- packages/turf-boolean-intersects/package.json | 12 +- packages/turf-boolean-intersects/test.ts | 5 +- packages/turf-boolean-overlap/bench.ts | 5 +- packages/turf-boolean-overlap/package.json | 12 +- packages/turf-boolean-overlap/test.ts | 5 +- packages/turf-boolean-parallel/bench.ts | 5 +- packages/turf-boolean-parallel/package.json | 12 +- packages/turf-boolean-parallel/test.ts | 5 +- .../turf-boolean-point-in-polygon/bench.ts | 6 +- .../package.json | 12 +- .../turf-boolean-point-in-polygon/test.ts | 6 +- packages/turf-boolean-point-on-line/bench.ts | 5 +- .../turf-boolean-point-on-line/package.json | 12 +- packages/turf-boolean-point-on-line/test.ts | 5 +- packages/turf-boolean-touches/bench.ts | 5 +- packages/turf-boolean-touches/package.json | 14 +- packages/turf-boolean-touches/test.ts | 5 +- packages/turf-boolean-touches/types.ts | 2 +- packages/turf-boolean-valid/bench.ts | 5 +- packages/turf-boolean-valid/package.json | 12 +- packages/turf-boolean-valid/test.ts | 5 +- packages/turf-boolean-within/bench.ts | 5 +- packages/turf-boolean-within/package.json | 14 +- packages/turf-boolean-within/test.ts | 5 +- packages/turf-boolean-within/types.ts | 2 +- packages/turf-buffer/bench.ts | 5 +- packages/turf-buffer/package.json | 19 +- packages/turf-buffer/test.ts | 5 +- packages/turf-buffer/types.ts | 2 +- packages/turf-center-mean/bench.ts | 5 +- packages/turf-center-mean/package.json | 14 +- packages/turf-center-mean/test.ts | 5 +- packages/turf-center-mean/types.ts | 2 +- packages/turf-center-median/bench.ts | 2 +- packages/turf-center-median/package.json | 12 +- packages/turf-center-median/test.ts | 5 +- packages/turf-center-of-mass/bench.ts | 3 + packages/turf-center-of-mass/package.json | 14 +- packages/turf-center-of-mass/test.ts | 5 +- packages/turf-center-of-mass/types.ts | 2 +- packages/turf-center/bench.ts | 5 +- packages/turf-center/package.json | 14 +- packages/turf-center/test.ts | 5 +- packages/turf-center/types.ts | 2 +- packages/turf-centroid/bench.ts | 5 +- packages/turf-centroid/package.json | 14 +- packages/turf-centroid/test.ts | 5 +- packages/turf-centroid/types.ts | 2 +- packages/turf-circle/bench.ts | 2 +- packages/turf-circle/package.json | 14 +- packages/turf-circle/test.ts | 5 +- packages/turf-circle/types.ts | 2 +- packages/turf-clean-coords/bench.ts | 5 +- packages/turf-clean-coords/package.json | 14 +- packages/turf-clean-coords/test.ts | 5 +- packages/turf-clean-coords/types.ts | 2 +- packages/turf-clone/bench.ts | 2 +- packages/turf-clone/package.json | 14 +- packages/turf-clone/test.ts | 2 +- packages/turf-clone/types.ts | 2 +- packages/turf-clusters-dbscan/bench.ts | 5 +- packages/turf-clusters-dbscan/index.ts | 3 +- .../turf-clusters-dbscan/lib/rbush-export.ts | 7 + packages/turf-clusters-dbscan/package.json | 15 +- packages/turf-clusters-dbscan/test.ts | 7 +- packages/turf-clusters-dbscan/types.ts | 2 +- packages/turf-clusters-kmeans/bench.ts | 5 +- packages/turf-clusters-kmeans/package.json | 14 +- packages/turf-clusters-kmeans/test.ts | 7 +- packages/turf-clusters-kmeans/types.ts | 2 +- packages/turf-clusters/bench.ts | 2 +- packages/turf-clusters/package.json | 14 +- packages/turf-clusters/test.ts | 2 +- packages/turf-clusters/types.ts | 4 +- packages/turf-collect/bench.ts | 2 +- packages/turf-collect/index.ts | 2 +- packages/turf-collect/lib/rbush-export.ts | 7 + packages/turf-collect/package.json | 12 +- packages/turf-collect/test.ts | 2 +- packages/turf-combine/bench.ts | 2 +- packages/turf-combine/package.json | 12 +- packages/turf-combine/test.ts | 2 +- packages/turf-concave/bench.ts | 5 +- packages/turf-concave/index.ts | 2 +- packages/turf-concave/lib/turf-dissolve.ts | 4 +- packages/turf-concave/package.json | 12 +- packages/turf-concave/test.ts | 5 +- packages/turf-convex/bench.ts | 5 +- packages/turf-convex/package.json | 12 +- packages/turf-convex/test.ts | 5 +- packages/turf-destination/bench.ts | 2 +- packages/turf-destination/package.json | 12 +- packages/turf-destination/test.ts | 5 +- packages/turf-difference/bench.ts | 5 +- packages/turf-difference/package.json | 12 +- packages/turf-difference/test.ts | 5 +- packages/turf-directional-mean/bench.ts | 5 +- packages/turf-directional-mean/package.json | 12 +- packages/turf-directional-mean/test.ts | 5 +- packages/turf-dissolve/bench.ts | 5 +- packages/turf-dissolve/package.json | 12 +- packages/turf-dissolve/test.ts | 5 +- packages/turf-distance-weight/bench.ts | 5 +- packages/turf-distance-weight/package.json | 12 +- packages/turf-distance-weight/test.ts | 5 +- packages/turf-distance/bench.ts | 2 +- packages/turf-distance/package.json | 12 +- packages/turf-distance/test.ts | 5 +- packages/turf-ellipse/bench.ts | 2 +- packages/turf-ellipse/package.json | 12 +- packages/turf-ellipse/test.ts | 5 +- packages/turf-envelope/bench.ts | 5 +- packages/turf-envelope/package.json | 12 +- packages/turf-envelope/test.ts | 5 +- packages/turf-explode/bench.ts | 2 +- packages/turf-explode/package.json | 12 +- packages/turf-explode/test.ts | 5 +- packages/turf-flatten/bench.ts | 5 +- packages/turf-flatten/package.json | 14 +- packages/turf-flatten/test.ts | 5 +- packages/turf-flatten/types.ts | 2 +- packages/turf-flip/bench.ts | 5 +- packages/turf-flip/package.json | 14 +- packages/turf-flip/test.ts | 5 +- packages/turf-flip/types.ts | 2 +- packages/turf-geojson-rbush/bench.ts | 2 +- packages/turf-geojson-rbush/package.json | 19 +- packages/turf-geojson-rbush/test.ts | 5 +- packages/turf-geojson-rbush/types.ts | 2 +- packages/turf-great-circle/bench.ts | 2 +- packages/turf-great-circle/index.js | 2 +- packages/turf-great-circle/package.json | 19 +- packages/turf-great-circle/test.ts | 5 +- packages/turf-great-circle/types.ts | 2 +- packages/turf-helpers/bench.ts | 2 +- packages/turf-helpers/index.ts | 6 +- packages/turf-helpers/package.json | 14 +- packages/turf-helpers/test.ts | 4 +- packages/turf-helpers/types.ts | 2 +- packages/turf-hex-grid/bench.ts | 2 +- packages/turf-hex-grid/package.json | 14 +- packages/turf-hex-grid/test.ts | 9 +- packages/turf-hex-grid/types.ts | 2 +- packages/turf-interpolate/bench.ts | 5 +- packages/turf-interpolate/package.json | 19 +- packages/turf-interpolate/test.ts | 9 +- packages/turf-interpolate/types.ts | 2 +- packages/turf-intersect/bench.ts | 5 +- packages/turf-intersect/package.json | 14 +- packages/turf-intersect/test.ts | 5 +- packages/turf-intersect/types.ts | 2 +- packages/turf-invariant/bench.ts | 4 +- packages/turf-invariant/package.json | 14 +- packages/turf-invariant/test.ts | 2 +- packages/turf-invariant/types.ts | 2 +- packages/turf-isobands/bench.ts | 7 +- packages/turf-isobands/index.ts | 2 +- packages/turf-isobands/package.json | 12 +- packages/turf-isobands/test.ts | 7 +- packages/turf-isolines/bench.ts | 7 +- packages/turf-isolines/index.ts | 2 +- packages/turf-isolines/package.json | 14 +- packages/turf-isolines/test.ts | 7 +- packages/turf-isolines/types.ts | 2 +- packages/turf-kinks/bench.ts | 5 +- packages/turf-kinks/index.ts | 2 +- .../lib/sweepline-intersections-export.ts | 7 + packages/turf-kinks/package.json | 14 +- packages/turf-kinks/test.ts | 5 +- packages/turf-kinks/types.ts | 2 +- packages/turf-length/bench.ts | 5 +- packages/turf-length/package.json | 12 +- packages/turf-length/test.ts | 5 +- packages/turf-line-arc/bench.ts | 5 +- packages/turf-line-arc/package.json | 14 +- packages/turf-line-arc/test.ts | 5 +- packages/turf-line-arc/types.ts | 2 +- packages/turf-line-chunk/bench.ts | 5 +- packages/turf-line-chunk/package.json | 19 +- packages/turf-line-chunk/test.ts | 5 +- packages/turf-line-chunk/types.ts | 2 +- packages/turf-line-intersect/bench.ts | 5 +- packages/turf-line-intersect/index.ts | 3 +- .../lib/sweepline-intersections-export.ts | 7 + packages/turf-line-intersect/package.json | 12 +- packages/turf-line-intersect/test.ts | 6 +- packages/turf-line-offset/bench.ts | 5 +- packages/turf-line-offset/index.js | 2 +- packages/turf-line-offset/package.json | 19 +- packages/turf-line-offset/test.ts | 5 +- packages/turf-line-offset/types.ts | 2 +- packages/turf-line-overlap/bench.ts | 5 +- packages/turf-line-overlap/package.json | 14 +- packages/turf-line-overlap/test.ts | 5 +- packages/turf-line-overlap/types.ts | 2 +- packages/turf-line-segment/bench.ts | 5 +- packages/turf-line-segment/package.json | 12 +- packages/turf-line-segment/test.ts | 5 +- packages/turf-line-slice-along/bench.ts | 6 +- packages/turf-line-slice-along/package.json | 17 +- packages/turf-line-slice-along/test.ts | 5 +- packages/turf-line-slice/bench.ts | 6 +- packages/turf-line-slice/package.json | 17 +- packages/turf-line-slice/test.ts | 5 +- packages/turf-line-split/bench.ts | 5 +- packages/turf-line-split/package.json | 17 +- packages/turf-line-split/test.ts | 5 +- packages/turf-line-to-polygon/bench.ts | 5 +- packages/turf-line-to-polygon/package.json | 14 +- packages/turf-line-to-polygon/test.ts | 5 +- packages/turf-line-to-polygon/types.ts | 2 +- packages/turf-mask/bench.ts | 5 +- packages/turf-mask/package.json | 19 +- packages/turf-mask/test.ts | 5 +- packages/turf-mask/types.ts | 2 +- packages/turf-meta/bench.ts | 2 +- packages/turf-meta/package.json | 18 +- packages/turf-meta/test.ts | 2 +- packages/turf-meta/types.ts | 4 +- packages/turf-midpoint/bench.ts | 2 +- packages/turf-midpoint/package.json | 16 +- packages/turf-midpoint/test.ts | 2 +- packages/turf-moran-index/bench.ts | 5 +- packages/turf-moran-index/package.json | 12 +- packages/turf-moran-index/test.ts | 5 +- .../turf-nearest-neighbor-analysis/bench.ts | 5 +- .../package.json | 12 +- .../turf-nearest-neighbor-analysis/test.ts | 5 +- packages/turf-nearest-point-on-line/bench.ts | 5 +- .../turf-nearest-point-on-line/package.json | 13 +- packages/turf-nearest-point-on-line/test.ts | 5 +- packages/turf-nearest-point-on-line/types.ts | 2 +- packages/turf-nearest-point-to-line/bench.ts | 5 +- .../turf-nearest-point-to-line/package.json | 14 +- packages/turf-nearest-point-to-line/test.ts | 5 +- packages/turf-nearest-point-to-line/types.ts | 2 +- packages/turf-nearest-point/bench.ts | 5 +- packages/turf-nearest-point/package.json | 18 +- packages/turf-nearest-point/test.ts | 5 +- packages/turf-nearest-point/types.ts | 2 +- packages/turf-planepoint/bench.ts | 2 +- packages/turf-planepoint/package.json | 17 +- packages/turf-planepoint/test.ts | 2 +- packages/turf-planepoint/types.ts | 2 +- packages/turf-point-grid/bench.ts | 2 +- packages/turf-point-grid/package.json | 14 +- packages/turf-point-grid/test.ts | 5 +- packages/turf-point-grid/types.ts | 2 +- packages/turf-point-on-feature/bench.ts | 5 +- packages/turf-point-on-feature/package.json | 15 +- packages/turf-point-on-feature/test.ts | 5 +- packages/turf-point-to-line-distance/bench.ts | 5 +- .../turf-point-to-line-distance/package.json | 14 +- packages/turf-point-to-line-distance/test.ts | 5 +- packages/turf-point-to-line-distance/types.ts | 2 +- packages/turf-points-within-polygon/bench.ts | 2 +- .../turf-points-within-polygon/package.json | 14 +- packages/turf-points-within-polygon/test.ts | 2 +- packages/turf-points-within-polygon/types.ts | 2 +- packages/turf-polygon-smooth/bench.ts | 5 +- packages/turf-polygon-smooth/package.json | 14 +- packages/turf-polygon-smooth/test.ts | 5 +- packages/turf-polygon-smooth/types.ts | 2 +- packages/turf-polygon-tangents/bench.ts | 5 +- packages/turf-polygon-tangents/package.json | 14 +- packages/turf-polygon-tangents/test.ts | 5 +- packages/turf-polygon-tangents/types.ts | 2 +- packages/turf-polygon-to-line/bench.ts | 5 +- packages/turf-polygon-to-line/package.json | 12 +- packages/turf-polygon-to-line/test.ts | 5 +- packages/turf-polygonize/bench.ts | 5 +- packages/turf-polygonize/index.ts | 4 +- packages/turf-polygonize/lib/Edge.ts | 6 +- packages/turf-polygonize/lib/EdgeRing.ts | 4 +- packages/turf-polygonize/lib/Graph.ts | 6 +- packages/turf-polygonize/lib/Node.ts | 4 +- packages/turf-polygonize/package.json | 14 +- packages/turf-polygonize/test.ts | 5 +- packages/turf-polygonize/types.ts | 2 +- packages/turf-projection/bench.ts | 5 +- packages/turf-projection/package.json | 14 +- packages/turf-projection/test.ts | 5 +- packages/turf-projection/types.ts | 4 +- packages/turf-quadrat-analysis/bench.ts | 2 +- packages/turf-quadrat-analysis/package.json | 12 +- packages/turf-quadrat-analysis/test.ts | 5 +- packages/turf-random/bench.ts | 2 +- packages/turf-random/package.json | 12 +- packages/turf-random/test.ts | 2 +- packages/turf-rectangle-grid/bench.ts | 2 +- packages/turf-rectangle-grid/package.json | 12 +- packages/turf-rectangle-grid/test.ts | 5 +- packages/turf-rewind/bench.ts | 5 +- packages/turf-rewind/package.json | 14 +- packages/turf-rewind/test.ts | 5 +- packages/turf-rewind/types.ts | 2 +- packages/turf-rhumb-bearing/bench.ts | 2 +- packages/turf-rhumb-bearing/package.json | 12 +- packages/turf-rhumb-bearing/test.ts | 5 +- packages/turf-rhumb-destination/bench.ts | 2 +- packages/turf-rhumb-destination/package.json | 12 +- packages/turf-rhumb-destination/test.ts | 5 +- packages/turf-rhumb-distance/bench.ts | 2 +- packages/turf-rhumb-distance/package.json | 12 +- packages/turf-rhumb-distance/test.ts | 5 +- packages/turf-sample/bench.ts | 2 +- packages/turf-sample/package.json | 12 +- packages/turf-sample/test.ts | 2 +- packages/turf-sector/bench.ts | 5 +- packages/turf-sector/package.json | 14 +- packages/turf-sector/test.ts | 5 +- packages/turf-sector/types.ts | 2 +- packages/turf-shortest-path/bench.ts | 5 +- packages/turf-shortest-path/index.ts | 2 +- packages/turf-shortest-path/package.json | 14 +- packages/turf-shortest-path/test.ts | 5 +- packages/turf-shortest-path/types.ts | 2 +- packages/turf-simplify/bench.ts | 5 +- packages/turf-simplify/index.ts | 2 +- packages/turf-simplify/package.json | 14 +- packages/turf-simplify/test.ts | 5 +- packages/turf-simplify/types.ts | 2 +- packages/turf-square-grid/bench.ts | 2 +- packages/turf-square-grid/package.json | 12 +- packages/turf-square-grid/test.ts | 5 +- packages/turf-square/bench.ts | 2 +- packages/turf-square/package.json | 15 +- packages/turf-square/test.ts | 2 +- .../bench.ts | 2 +- .../package.json | 19 +- .../turf-standard-deviational-ellipse/test.ts | 5 +- .../types.ts | 2 +- packages/turf-tag/bench.ts | 2 +- packages/turf-tag/package.json | 12 +- packages/turf-tag/test.ts | 5 +- packages/turf-tesselate/bench.ts | 2 +- packages/turf-tesselate/package.json | 16 +- packages/turf-tesselate/test.ts | 2 +- packages/turf-tin/bench.ts | 5 +- packages/turf-tin/package.json | 14 +- packages/turf-tin/test.ts | 12 +- packages/turf-tin/types.ts | 2 +- packages/turf-transform-rotate/bench.ts | 5 +- packages/turf-transform-rotate/package.json | 19 +- packages/turf-transform-rotate/test.ts | 5 +- packages/turf-transform-rotate/types.ts | 2 +- packages/turf-transform-scale/bench.ts | 5 +- packages/turf-transform-scale/package.json | 19 +- packages/turf-transform-scale/test.ts | 5 +- packages/turf-transform-scale/types.ts | 2 +- packages/turf-transform-translate/bench.ts | 5 +- .../turf-transform-translate/package.json | 19 +- packages/turf-transform-translate/test.ts | 5 +- packages/turf-transform-translate/types.ts | 2 +- packages/turf-triangle-grid/bench.ts | 2 +- packages/turf-triangle-grid/package.json | 14 +- packages/turf-triangle-grid/test.ts | 5 +- packages/turf-triangle-grid/types.ts | 2 +- packages/turf-truncate/bench.ts | 5 +- packages/turf-truncate/package.json | 14 +- packages/turf-truncate/test.ts | 5 +- packages/turf-truncate/types.ts | 2 +- packages/turf-union/bench.ts | 5 +- packages/turf-union/package.json | 14 +- packages/turf-union/test.ts | 5 +- packages/turf-union/types.ts | 2 +- packages/turf-unkink-polygon/bench.ts | 5 +- packages/turf-unkink-polygon/index.js | 2 +- packages/turf-unkink-polygon/package.json | 19 +- packages/turf-unkink-polygon/test.ts | 5 +- packages/turf-unkink-polygon/types.ts | 2 +- packages/turf-voronoi/bench.ts | 5 +- packages/turf-voronoi/package.json | 17 +- packages/turf-voronoi/test.ts | 5 +- packages/turf/package.json | 13 +- packages/turf/test.ts | 11 +- pnpm-lock.yaml | 271 +++++++++++++----- tsup.config.ts | 3 +- 425 files changed, 1912 insertions(+), 1214 deletions(-) create mode 100644 packages/turf-clusters-dbscan/lib/rbush-export.ts create mode 100644 packages/turf-collect/lib/rbush-export.ts create mode 100644 packages/turf-kinks/lib/sweepline-intersections-export.ts create mode 100644 packages/turf-line-intersect/lib/sweepline-intersections-export.ts diff --git a/.monorepolint.config.mjs b/.monorepolint.config.mjs index b4e165729c..c3bf85e249 100644 --- a/.monorepolint.config.mjs +++ b/.monorepolint.config.mjs @@ -88,21 +88,29 @@ export default { packageEntry({ options: { entries: { + type: "module", + main: "dist/cjs/index.cjs", + module: "dist/esm/index.js", + types: "dist/esm/index.d.ts", + sideEffects: false, + publishConfig: { + access: "public", + }, // @turf/turf is commonly consumed through CDNs, moving this output file is a breaking change for anyone // who has a hardcoded reference to this specific file, instead of letting the CDN pick the path. // Example of a URL that will break: https://unpkg.com/@turf/turf/dist/turf.min.js // Example of a URL that will keep working: https://unpkg.com/@turf/turf browser: "turf.min.js", - files: ["dist", "index.d.ts", "turf.min.js"], + files: ["dist", "turf.min.js"], exports: { "./package.json": "./package.json", ".": { import: { - types: "./dist/esm/index.d.mts", - default: "./dist/esm/index.mjs", + types: "./dist/esm/index.d.ts", + default: "./dist/esm/index.js", }, require: { - types: "./dist/cjs/index.d.ts", + types: "./dist/cjs/index.d.cts", default: "./dist/cjs/index.cjs", }, }, @@ -115,9 +123,10 @@ export default { packageEntry({ options: { entries: { + type: "module", main: "dist/cjs/index.cjs", - module: "dist/esm/index.mjs", - types: "dist/cjs/index.d.ts", + module: "dist/esm/index.js", + types: "dist/esm/index.d.ts", sideEffects: false, publishConfig: { access: "public", @@ -126,11 +135,11 @@ export default { "./package.json": "./package.json", ".": { import: { - types: "./dist/esm/index.d.mts", - default: "./dist/esm/index.mjs", + types: "./dist/esm/index.d.ts", + default: "./dist/esm/index.js", }, require: { - types: "./dist/cjs/index.d.ts", + types: "./dist/cjs/index.d.cts", default: "./dist/cjs/index.cjs", }, }, @@ -146,16 +155,7 @@ export default { files: ["dist"], }, }, - includePackages: TS_PACKAGES, - }), - - packageEntry({ - options: { - entries: { - files: ["dist", "index.d.ts"], - }, - }, - includePackages: JS_PACKAGES, + includePackages: [...TS_PACKAGES, ...JS_PACKAGES], }), packageEntry({ @@ -208,7 +208,8 @@ export default { packageScript({ options: { scripts: { - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts", + "test:types": + "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts", }, }, includePackages: TYPES_PACKAGES, diff --git a/package.json b/package.json index 1d83d17dcd..0522239767 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "scripts": { "docs": "tsx ./scripts/generate-readmes.ts", "lint": "npm-run-all lint:*", - "lint:docs": "documentation lint packages/turf-*/index.js packages/turf-*/index.mjs", + "lint:docs": "documentation lint packages/turf-*/index.js", "lint:escheck-cjs": "es-check es8 packages/*/dist/cjs/index.cjs packages/turf/turf.min.js", - "lint:escheck-esm": "es-check --module es8 packages/*/dist/esm/index.mjs", + "lint:escheck-esm": "es-check --module es8 packages/*/dist/esm/index.js", "lint:escheck-web": "es-check es5 packages/turf/turf.min.js", "lint:eslint": "eslint packages", "lint:mrl": "mrl check", diff --git a/packages/turf-along/bench.ts b/packages/turf-along/bench.ts index a4d54351d1..cc06666e35 100644 --- a/packages/turf-along/bench.ts +++ b/packages/turf-along/bench.ts @@ -1,8 +1,12 @@ import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; import Benchmark from "benchmark"; -import { along } from "./index"; +import { along } from "./index.js"; import { Feature, LineString } from "geojson"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + const line: Feature = { type: "Feature", properties: {}, diff --git a/packages/turf-along/package.json b/packages/turf-along/package.json index df48d1dedd..e5ba692659 100644 --- a/packages/turf-along/package.json +++ b/packages/turf-along/package.json @@ -23,19 +23,19 @@ "turf", "distance" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-along/test.ts b/packages/turf-along/test.ts index 2fa6e5c184..86df4ee8bd 100644 --- a/packages/turf-along/test.ts +++ b/packages/turf-along/test.ts @@ -1,10 +1,13 @@ import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { Units, featureCollection } from "@turf/helpers"; -import { along } from "./index"; +import { along } from "./index.js"; import { Feature, LineString } from "geojson"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + const line: Feature = loadJsonFileSync( path.join(__dirname, "test", "fixtures", "dc-line.geojson") ); diff --git a/packages/turf-angle/bench.ts b/packages/turf-angle/bench.ts index 9b36fb7106..62b7041a70 100644 --- a/packages/turf-angle/bench.ts +++ b/packages/turf-angle/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { angle } from "./index"; +import { angle } from "./index.js"; /** * Benchmark Results diff --git a/packages/turf-angle/package.json b/packages/turf-angle/package.json index f02637d7ca..7b72b6ac1f 100644 --- a/packages/turf-angle/package.json +++ b/packages/turf-angle/package.json @@ -23,19 +23,19 @@ "turf", "angle" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-angle/test.ts b/packages/turf-angle/test.ts index 09fb0dcda1..a90afb5bb0 100644 --- a/packages/turf-angle/test.ts +++ b/packages/turf-angle/test.ts @@ -1,5 +1,6 @@ import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; @@ -8,7 +9,9 @@ import { bearing } from "@turf/bearing"; import { truncate } from "@turf/truncate"; import { distance } from "@turf/distance"; import { point, round, lineString, featureCollection } from "@turf/helpers"; -import { angle } from "./index"; +import { angle } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-angle", (t) => { glob diff --git a/packages/turf-area/bench.ts b/packages/turf-area/bench.ts index 6a95534e56..31b3fc06c4 100644 --- a/packages/turf-area/bench.ts +++ b/packages/turf-area/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { area } from "./index"; +import { area } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Define fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-area/package.json b/packages/turf-area/package.json index 5d475843a6..75f3b51772 100644 --- a/packages/turf-area/package.json +++ b/packages/turf-area/package.json @@ -22,19 +22,19 @@ "polygon", "multipolygon" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-area/test.ts b/packages/turf-area/test.ts index ace5f74b8e..904c045924 100644 --- a/packages/turf-area/test.ts +++ b/packages/turf-area/test.ts @@ -1,9 +1,12 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import { area } from "./index"; +import { area } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-bbox-clip/bench.ts b/packages/turf-bbox-clip/bench.ts index ef947eaf89..ae93604d67 100644 --- a/packages/turf-bbox-clip/bench.ts +++ b/packages/turf-bbox-clip/bench.ts @@ -1,9 +1,12 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; import { bbox } from "@turf/bbox"; -import { bboxClip } from "./index"; +import { bboxClip } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-bbox-clip/index.ts b/packages/turf-bbox-clip/index.ts index 1497748e49..8d9221a5b8 100644 --- a/packages/turf-bbox-clip/index.ts +++ b/packages/turf-bbox-clip/index.ts @@ -15,7 +15,7 @@ import { polygon, } from "@turf/helpers"; import { getGeom } from "@turf/invariant"; -import { lineclip, polygonclip } from "./lib/lineclip"; +import { lineclip, polygonclip } from "./lib/lineclip.js"; /** * Takes a {@link Feature} and a bbox and clips the feature to the bbox using diff --git a/packages/turf-bbox-clip/package.json b/packages/turf-bbox-clip/package.json index 95f20b85ef..4a2619cbf8 100644 --- a/packages/turf-bbox-clip/package.json +++ b/packages/turf-bbox-clip/package.json @@ -28,19 +28,19 @@ "bbox", "clip" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-bbox-clip/test.ts b/packages/turf-bbox-clip/test.ts index 8e8f10e134..9bd6116483 100644 --- a/packages/turf-bbox-clip/test.ts +++ b/packages/turf-bbox-clip/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point, feature, featureCollection } from "@turf/helpers"; import { bbox as turfBBox } from "@turf/bbox"; -import { bboxClip } from "./index"; +import { bboxClip } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-bbox-polygon/bench.ts b/packages/turf-bbox-polygon/bench.ts index 554b171122..a78f6ba18f 100644 --- a/packages/turf-bbox-polygon/bench.ts +++ b/packages/turf-bbox-polygon/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { bboxPolygon } from "./index"; +import { bboxPolygon } from "./index.js"; /** * Benchmark Results diff --git a/packages/turf-bbox-polygon/package.json b/packages/turf-bbox-polygon/package.json index 6c42da1e11..2c61cb10eb 100644 --- a/packages/turf-bbox-polygon/package.json +++ b/packages/turf-bbox-polygon/package.json @@ -23,19 +23,19 @@ "extent", "bbox" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-bbox-polygon/test.ts b/packages/turf-bbox-polygon/test.ts index f06bbb8a42..1423da3aa5 100644 --- a/packages/turf-bbox-polygon/test.ts +++ b/packages/turf-bbox-polygon/test.ts @@ -1,5 +1,5 @@ import test from "tape"; -import { bboxPolygon } from "./index"; +import { bboxPolygon } from "./index.js"; test("bbox-polygon", (t) => { const poly = bboxPolygon([0, 0, 10, 10]); diff --git a/packages/turf-bbox/bench.ts b/packages/turf-bbox/bench.ts index 890f295fa1..64febb6abe 100644 --- a/packages/turf-bbox/bench.ts +++ b/packages/turf-bbox/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { lineString } from "@turf/helpers"; -import { bbox } from "./index"; +import { bbox } from "./index.js"; const line = lineString([ [-74, 40], diff --git a/packages/turf-bbox/package.json b/packages/turf-bbox/package.json index 010e7b7548..60d80caaf2 100644 --- a/packages/turf-bbox/package.json +++ b/packages/turf-bbox/package.json @@ -24,19 +24,19 @@ "featurecollection", "geojson" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-bbox/test.ts b/packages/turf-bbox/test.ts index 8ec8408f88..d82a6e43f6 100644 --- a/packages/turf-bbox/test.ts +++ b/packages/turf-bbox/test.ts @@ -8,7 +8,7 @@ import { multiLineString, featureCollection, } from "@turf/helpers"; -import { bbox } from "./index"; +import { bbox } from "./index.js"; // Fixtures const pt = point([102.0, 0.5]); diff --git a/packages/turf-bearing/bench.ts b/packages/turf-bearing/bench.ts index a73201da26..23ed74c42d 100644 --- a/packages/turf-bearing/bench.ts +++ b/packages/turf-bearing/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { bearing } from "./index"; +import { bearing } from "./index.js"; var start = [-75.4, 39.4]; var end = [-75.534, 39.123]; diff --git a/packages/turf-bearing/package.json b/packages/turf-bearing/package.json index c0d470209d..bfb1c8d749 100644 --- a/packages/turf-bearing/package.json +++ b/packages/turf-bearing/package.json @@ -20,19 +20,19 @@ "turf", "bearing" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-bearing/test.ts b/packages/turf-bearing/test.ts index 2f9221aece..c22e93edcc 100644 --- a/packages/turf-bearing/test.ts +++ b/packages/turf-bearing/test.ts @@ -1,9 +1,12 @@ import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { writeJsonFileSync } from "write-json-file"; import { destination } from "@turf/destination"; import { point, lineString, featureCollection } from "@turf/helpers"; -import { bearing } from "./index"; +import { bearing } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const out = path.join(__dirname, "test", "out") + path.sep; diff --git a/packages/turf-bezier-spline/bench.ts b/packages/turf-bezier-spline/bench.ts index 4c27d1b992..4f886db616 100644 --- a/packages/turf-bezier-spline/bench.ts +++ b/packages/turf-bezier-spline/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { bezierSpline } from "./index"; +import { bezierSpline } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-bezier-spline/index.ts b/packages/turf-bezier-spline/index.ts index ab26e0bceb..1334bbfc64 100644 --- a/packages/turf-bezier-spline/index.ts +++ b/packages/turf-bezier-spline/index.ts @@ -1,7 +1,7 @@ import { Feature, LineString, GeoJsonProperties } from "geojson"; import { lineString } from "@turf/helpers"; import { getGeom } from "@turf/invariant"; -import { Spline } from "./lib/spline"; +import { Spline } from "./lib/spline.js"; /** * Takes a {@link LineString|line} and returns a curved version diff --git a/packages/turf-bezier-spline/package.json b/packages/turf-bezier-spline/package.json index c0336c6589..00ee89b2fa 100644 --- a/packages/turf-bezier-spline/package.json +++ b/packages/turf-bezier-spline/package.json @@ -23,19 +23,19 @@ "curve", "linestring" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-bezier-spline/test.ts b/packages/turf-bezier-spline/test.ts index 142153415e..69dcd7fff8 100644 --- a/packages/turf-bezier-spline/test.ts +++ b/packages/turf-bezier-spline/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureCollection } from "@turf/helpers"; -import { bezierSpline } from "./index"; +import { bezierSpline } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-boolean-clockwise/bench.ts b/packages/turf-boolean-clockwise/bench.ts index b87d3655e2..d885699950 100755 --- a/packages/turf-boolean-clockwise/bench.ts +++ b/packages/turf-boolean-clockwise/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import Benchmark from "benchmark"; import { loadJsonFileSync } from "load-json-file"; -import { booleanClockwise as isClockwise } from "./index"; +import { booleanClockwise as isClockwise } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-clockwise/package.json b/packages/turf-boolean-clockwise/package.json index d0e4103a0f..25786feb24 100755 --- a/packages/turf-boolean-clockwise/package.json +++ b/packages/turf-boolean-clockwise/package.json @@ -27,19 +27,19 @@ "clockwise", "boolean" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-clockwise/test.ts b/packages/turf-boolean-clockwise/test.ts index 30de5d4fdf..485532d92e 100644 --- a/packages/turf-boolean-clockwise/test.ts +++ b/packages/turf-boolean-clockwise/test.ts @@ -1,9 +1,12 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { lineString } from "@turf/helpers"; -import { booleanClockwise as isClockwise } from "./index"; +import { booleanClockwise as isClockwise } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("isClockwise#fixtures", (t) => { // True Fixtures diff --git a/packages/turf-boolean-concave/bench.ts b/packages/turf-boolean-concave/bench.ts index a40b814ff1..3a71fb76a6 100644 --- a/packages/turf-boolean-concave/bench.ts +++ b/packages/turf-boolean-concave/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import Benchmark from "benchmark"; import { loadJsonFileSync } from "load-json-file"; -import { booleanConcave as concave } from "./index"; +import { booleanConcave as concave } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-concave/package.json b/packages/turf-boolean-concave/package.json index 1c73a09b0b..ed6215d088 100644 --- a/packages/turf-boolean-concave/package.json +++ b/packages/turf-boolean-concave/package.json @@ -26,19 +26,19 @@ "convex", "boolean" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-concave/test.ts b/packages/turf-boolean-concave/test.ts index 8829a087ae..07d9ff6289 100644 --- a/packages/turf-boolean-concave/test.ts +++ b/packages/turf-boolean-concave/test.ts @@ -1,10 +1,13 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { polygon } from "@turf/helpers"; import { booleanConcave as isConcave } from "./index.js"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + test("isConcave#fixtures", (t) => { // True Fixtures glob diff --git a/packages/turf-boolean-contains/bench.ts b/packages/turf-boolean-contains/bench.ts index ec8b6becea..ed26b46d15 100644 --- a/packages/turf-boolean-contains/bench.ts +++ b/packages/turf-boolean-contains/bench.ts @@ -1,9 +1,12 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import Benchmark from "benchmark"; import { loadJsonFileSync } from "load-json-file"; import { bbox } from "@turf/bbox"; -import { booleanContains as contains } from "./index"; +import { booleanContains as contains } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-contains/package.json b/packages/turf-boolean-contains/package.json index 403df13a8a..70d518fbeb 100644 --- a/packages/turf-boolean-contains/package.json +++ b/packages/turf-boolean-contains/package.json @@ -26,19 +26,19 @@ "boolean", "de-9im" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-contains/test.ts b/packages/turf-boolean-contains/test.ts index 8fc8de0bd3..dc8b3596d4 100644 --- a/packages/turf-boolean-contains/test.ts +++ b/packages/turf-boolean-contains/test.ts @@ -1,11 +1,14 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { point } from "@turf/helpers"; import booleanJSTS from "boolean-jsts"; import shapely from "boolean-shapely"; -import { booleanContains as contains } from "./index"; +import { booleanContains as contains } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-contains", (t) => { // True Fixtures diff --git a/packages/turf-boolean-crosses/bench.ts b/packages/turf-boolean-crosses/bench.ts index 5560880dd9..0645ad7efc 100644 --- a/packages/turf-boolean-crosses/bench.ts +++ b/packages/turf-boolean-crosses/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import Benchmark from "benchmark"; import { loadJsonFileSync } from "load-json-file"; -import { booleanCrosses as crosses } from "./index"; +import { booleanCrosses as crosses } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-crosses/package.json b/packages/turf-boolean-crosses/package.json index 805ecf8903..c9bf30725a 100644 --- a/packages/turf-boolean-crosses/package.json +++ b/packages/turf-boolean-crosses/package.json @@ -26,19 +26,19 @@ "boolean", "de-9im" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-crosses/test.ts b/packages/turf-boolean-crosses/test.ts index df685bcfb5..e970dc45cd 100644 --- a/packages/turf-boolean-crosses/test.ts +++ b/packages/turf-boolean-crosses/test.ts @@ -1,9 +1,12 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import shapely from "boolean-shapely"; -import { booleanCrosses as crosses } from "./index"; +import { booleanCrosses as crosses } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-crosses", (t) => { // True Fixtures diff --git a/packages/turf-boolean-disjoint/bench.ts b/packages/turf-boolean-disjoint/bench.ts index 10bb47ed16..e253da48bb 100644 --- a/packages/turf-boolean-disjoint/bench.ts +++ b/packages/turf-boolean-disjoint/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { booleanDisjoint as disjoint } from "./index"; +import { booleanDisjoint as disjoint } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-disjoint/package.json b/packages/turf-boolean-disjoint/package.json index 9b84e0647c..597a6d1a18 100644 --- a/packages/turf-boolean-disjoint/package.json +++ b/packages/turf-boolean-disjoint/package.json @@ -26,19 +26,19 @@ "boolean", "de-9im" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-disjoint/test.ts b/packages/turf-boolean-disjoint/test.ts index b0c12070dc..78bf20aa9e 100644 --- a/packages/turf-boolean-disjoint/test.ts +++ b/packages/turf-boolean-disjoint/test.ts @@ -1,9 +1,12 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import shapely from "boolean-shapely"; -import { booleanDisjoint as disjoint } from "./index"; +import { booleanDisjoint as disjoint } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-disjoint", (t) => { // True Fixtures diff --git a/packages/turf-boolean-equal/bench.ts b/packages/turf-boolean-equal/bench.ts index 9de3b7cb3e..7540568535 100644 --- a/packages/turf-boolean-equal/bench.ts +++ b/packages/turf-boolean-equal/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { booleanEqual as equal } from "./index"; +import { booleanEqual as equal } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-equal/package.json b/packages/turf-boolean-equal/package.json index b0ccd910fa..b4972db16b 100644 --- a/packages/turf-boolean-equal/package.json +++ b/packages/turf-boolean-equal/package.json @@ -29,19 +29,19 @@ "equal", "boolean-equal" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-equal/test.ts b/packages/turf-boolean-equal/test.ts index c0346666f7..cca9380606 100644 --- a/packages/turf-boolean-equal/test.ts +++ b/packages/turf-boolean-equal/test.ts @@ -1,10 +1,13 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import shapely from "boolean-shapely"; import { point, lineString, polygon } from "@turf/helpers"; -import { booleanEqual as equal } from "./index"; +import { booleanEqual as equal } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-equal", (t) => { // True Fixtures diff --git a/packages/turf-boolean-intersects/bench.ts b/packages/turf-boolean-intersects/bench.ts index 2db4d67b25..d14936bffc 100644 --- a/packages/turf-boolean-intersects/bench.ts +++ b/packages/turf-boolean-intersects/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { booleanIntersects as intersects } from "./index"; +import { booleanIntersects as intersects } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-intersects/package.json b/packages/turf-boolean-intersects/package.json index 37898c1c44..c71878bea4 100644 --- a/packages/turf-boolean-intersects/package.json +++ b/packages/turf-boolean-intersects/package.json @@ -26,19 +26,19 @@ "boolean", "de-9im" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-intersects/test.ts b/packages/turf-boolean-intersects/test.ts index e79d797a34..6e553a9f09 100644 --- a/packages/turf-boolean-intersects/test.ts +++ b/packages/turf-boolean-intersects/test.ts @@ -1,9 +1,12 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import shapely from "boolean-shapely"; -import { booleanIntersects as intersects } from "./index"; +import { booleanIntersects as intersects } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-intersects", (t) => { // True Fixtures diff --git a/packages/turf-boolean-overlap/bench.ts b/packages/turf-boolean-overlap/bench.ts index ca5f9b93df..700aa0e754 100755 --- a/packages/turf-boolean-overlap/bench.ts +++ b/packages/turf-boolean-overlap/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { booleanOverlap as overlap } from "./index"; +import { booleanOverlap as overlap } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-overlap/package.json b/packages/turf-boolean-overlap/package.json index 037a627c36..a893a918e4 100755 --- a/packages/turf-boolean-overlap/package.json +++ b/packages/turf-boolean-overlap/package.json @@ -28,19 +28,19 @@ "overlap", "boolean-overlap" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-overlap/test.ts b/packages/turf-boolean-overlap/test.ts index c9a945bb4c..4b34f9de9d 100644 --- a/packages/turf-boolean-overlap/test.ts +++ b/packages/turf-boolean-overlap/test.ts @@ -1,5 +1,6 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import shapely from "boolean-shapely"; @@ -10,7 +11,9 @@ import { multiLineString, multiPolygon, } from "@turf/helpers"; -import { booleanOverlap as overlap } from "./index"; +import { booleanOverlap as overlap } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-overlap", (t) => { // True Fixtures diff --git a/packages/turf-boolean-parallel/bench.ts b/packages/turf-boolean-parallel/bench.ts index 5cd24ea4d6..0b6686532c 100644 --- a/packages/turf-boolean-parallel/bench.ts +++ b/packages/turf-boolean-parallel/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { booleanParallel } from "./index"; +import { booleanParallel } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-parallel/package.json b/packages/turf-boolean-parallel/package.json index 5cbe53efd0..b0dc0db461 100644 --- a/packages/turf-boolean-parallel/package.json +++ b/packages/turf-boolean-parallel/package.json @@ -25,19 +25,19 @@ "boolean", "boolean-parallel" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-parallel/test.ts b/packages/turf-boolean-parallel/test.ts index 5cbe9979b4..3f7de0d442 100644 --- a/packages/turf-boolean-parallel/test.ts +++ b/packages/turf-boolean-parallel/test.ts @@ -1,9 +1,12 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { lineString } from "@turf/helpers"; -import { booleanParallel } from "./index"; +import { booleanParallel } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-parallel", (t) => { // True Fixtures diff --git a/packages/turf-boolean-point-in-polygon/bench.ts b/packages/turf-boolean-point-in-polygon/bench.ts index 0e1032f5fe..e0b96847a3 100644 --- a/packages/turf-boolean-point-in-polygon/bench.ts +++ b/packages/turf-boolean-point-in-polygon/bench.ts @@ -1,7 +1,11 @@ import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; import Benchmark from "benchmark"; import { point, polygon } from "@turf/helpers"; -import { booleanPointInPolygon } from "./index"; +import { booleanPointInPolygon } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); var poly = polygon([ [ diff --git a/packages/turf-boolean-point-in-polygon/package.json b/packages/turf-boolean-point-in-polygon/package.json index 8489912788..74c9085245 100644 --- a/packages/turf-boolean-point-in-polygon/package.json +++ b/packages/turf-boolean-point-in-polygon/package.json @@ -24,19 +24,19 @@ "bin", "gis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-point-in-polygon/test.ts b/packages/turf-boolean-point-in-polygon/test.ts index 15eea40ad7..113e216574 100644 --- a/packages/turf-boolean-point-in-polygon/test.ts +++ b/packages/turf-boolean-point-in-polygon/test.ts @@ -1,8 +1,12 @@ import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { point } from "@turf/helpers"; import { polygon } from "@turf/helpers"; -import { booleanPointInPolygon } from "./index"; +import { booleanPointInPolygon } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("boolean-point-in-polygon -- featureCollection", function (t) { // test for a simple polygon diff --git a/packages/turf-boolean-point-on-line/bench.ts b/packages/turf-boolean-point-on-line/bench.ts index 607ac5c416..45fadb5333 100644 --- a/packages/turf-boolean-point-on-line/bench.ts +++ b/packages/turf-boolean-point-on-line/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { booleanPointOnLine } from "./index"; +import { booleanPointOnLine } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-point-on-line/package.json b/packages/turf-boolean-point-on-line/package.json index 90f8278714..349f2236a8 100644 --- a/packages/turf-boolean-point-on-line/package.json +++ b/packages/turf-boolean-point-on-line/package.json @@ -23,19 +23,19 @@ "turf", "booleanPointOnLine" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-point-on-line/test.ts b/packages/turf-boolean-point-on-line/test.ts index 2da0a3447c..bbf9d39faf 100644 --- a/packages/turf-boolean-point-on-line/test.ts +++ b/packages/turf-boolean-point-on-line/test.ts @@ -1,8 +1,11 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; -import { booleanPointOnLine as pointOnLine } from "./index"; +import { booleanPointOnLine as pointOnLine } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-point-on-line", (t) => { // True Fixtures diff --git a/packages/turf-boolean-touches/bench.ts b/packages/turf-boolean-touches/bench.ts index 7e40534fe3..7a15ce8fcb 100644 --- a/packages/turf-boolean-touches/bench.ts +++ b/packages/turf-boolean-touches/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { booleanTouches as touches } from "./index"; +import { booleanTouches as touches } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-touches/package.json b/packages/turf-boolean-touches/package.json index 6f08f7e589..6165148828 100644 --- a/packages/turf-boolean-touches/package.json +++ b/packages/turf-boolean-touches/package.json @@ -27,19 +27,19 @@ "touches", "boolean-touches" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-touches/test.ts b/packages/turf-boolean-touches/test.ts index 62f0d357da..a6af105942 100644 --- a/packages/turf-boolean-touches/test.ts +++ b/packages/turf-boolean-touches/test.ts @@ -1,10 +1,13 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import shapely from "boolean-shapely"; import booleanJSTS from "boolean-jsts"; -import { booleanTouches as touches } from "./index"; +import { booleanTouches as touches } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-touches", (t) => { // True Fixtures diff --git a/packages/turf-boolean-touches/types.ts b/packages/turf-boolean-touches/types.ts index 1475d68ee4..cafd1accb6 100644 --- a/packages/turf-boolean-touches/types.ts +++ b/packages/turf-boolean-touches/types.ts @@ -1,5 +1,5 @@ import * as helpers from "@turf/helpers"; -import { booleanTouches } from "./index"; +import { booleanTouches } from "./index.js"; const pt = helpers.point([0, 0]); const line = helpers.lineString([ diff --git a/packages/turf-boolean-valid/bench.ts b/packages/turf-boolean-valid/bench.ts index 6e20a4f760..5c615be354 100644 --- a/packages/turf-boolean-valid/bench.ts +++ b/packages/turf-boolean-valid/bench.ts @@ -1,9 +1,12 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import Benchmark from "benchmark"; import { loadJsonFileSync } from "load-json-file"; import { bbox } from "@turf/bbox"; -import { booleanValid as isValid } from "./index"; +import { booleanValid as isValid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-valid/package.json b/packages/turf-boolean-valid/package.json index d0f63e48a4..1dec9a6bc2 100644 --- a/packages/turf-boolean-valid/package.json +++ b/packages/turf-boolean-valid/package.json @@ -26,19 +26,19 @@ "boolean", "ogc" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-boolean-valid/test.ts b/packages/turf-boolean-valid/test.ts index 813c92235e..17b87cee64 100644 --- a/packages/turf-boolean-valid/test.ts +++ b/packages/turf-boolean-valid/test.ts @@ -1,8 +1,11 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; -import { booleanValid as isValid } from "./index"; +import { booleanValid as isValid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-valid", (t) => { // True Fixtures diff --git a/packages/turf-boolean-within/bench.ts b/packages/turf-boolean-within/bench.ts index 7e9619bdfe..5e97888f4e 100644 --- a/packages/turf-boolean-within/bench.ts +++ b/packages/turf-boolean-within/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { booleanWithin as within } from "./index"; +import { booleanWithin as within } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-boolean-within/package.json b/packages/turf-boolean-within/package.json index b653f30ebb..b9eb48c64d 100644 --- a/packages/turf-boolean-within/package.json +++ b/packages/turf-boolean-within/package.json @@ -27,19 +27,19 @@ "within", "boolean-within" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-within/test.ts b/packages/turf-boolean-within/test.ts index a2382300c6..5e8e4fcd84 100644 --- a/packages/turf-boolean-within/test.ts +++ b/packages/turf-boolean-within/test.ts @@ -1,10 +1,13 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import shapely from "boolean-shapely"; import booleanJSTS from "boolean-jsts"; -import { booleanWithin as within } from "./index"; +import { booleanWithin as within } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-boolean-within", (t) => { // True Fixtures diff --git a/packages/turf-boolean-within/types.ts b/packages/turf-boolean-within/types.ts index b0c870784c..190bcfd689 100644 --- a/packages/turf-boolean-within/types.ts +++ b/packages/turf-boolean-within/types.ts @@ -1,5 +1,5 @@ import * as helpers from "@turf/helpers"; -import { booleanWithin } from "./index"; +import { booleanWithin } from "./index.js"; const pt = helpers.point([0, 0]); const line = helpers.lineString([ diff --git a/packages/turf-buffer/bench.ts b/packages/turf-buffer/bench.ts index 481ab065f7..b7fa44a1d5 100644 --- a/packages/turf-buffer/bench.ts +++ b/packages/turf-buffer/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { buffer } from "./index"; +import { buffer } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-buffer/package.json b/packages/turf-buffer/package.json index 422ee10520..55232648cd 100644 --- a/packages/turf-buffer/package.json +++ b/packages/turf-buffer/package.json @@ -30,27 +30,26 @@ "geojson", "turf" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -58,10 +57,12 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-buffer/test.ts b/packages/turf-buffer/test.ts index 0c120f8513..0b230dafab 100644 --- a/packages/turf-buffer/test.ts +++ b/packages/turf-buffer/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; @@ -11,7 +12,9 @@ import { polygon, geometryCollection, } from "@turf/helpers"; -import { buffer } from "./index"; +import { buffer } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-buffer/types.ts b/packages/turf-buffer/types.ts index d4ed61b0b3..8a6ff304a0 100644 --- a/packages/turf-buffer/types.ts +++ b/packages/turf-buffer/types.ts @@ -9,7 +9,7 @@ import { geometryCollection, } from "@turf/helpers"; import { Point, LineString } from "geojson"; -import { buffer } from "./index"; +import { buffer } from "./index.js"; // Standard Geometry const pt = point([100, 0]); diff --git a/packages/turf-center-mean/bench.ts b/packages/turf-center-mean/bench.ts index 3bb1fff22c..a9d1b97f28 100644 --- a/packages/turf-center-mean/bench.ts +++ b/packages/turf-center-mean/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { centerMean } from "./index"; +import { centerMean } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const fixtures = glob .sync(path.join(__dirname, "test", "in", "*.geojson")) diff --git a/packages/turf-center-mean/package.json b/packages/turf-center-mean/package.json index f8bac7c1ee..e4704c96c0 100644 --- a/packages/turf-center-mean/package.json +++ b/packages/turf-center-mean/package.json @@ -28,19 +28,19 @@ "geo", "turf" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/center": "workspace:^", diff --git a/packages/turf-center-mean/test.ts b/packages/turf-center-mean/test.ts index 61dfddd73a..64589adf94 100644 --- a/packages/turf-center-mean/test.ts +++ b/packages/turf-center-mean/test.ts @@ -1,13 +1,16 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureEach, coordEach } from "@turf/meta"; import { lineString, featureCollection } from "@turf/helpers"; import { center } from "@turf/center"; -import { centerMean } from "./index"; +import { centerMean } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-center-mean", (t) => { glob diff --git a/packages/turf-center-mean/types.ts b/packages/turf-center-mean/types.ts index 3ed5bdef4d..8c0d54ab02 100644 --- a/packages/turf-center-mean/types.ts +++ b/packages/turf-center-mean/types.ts @@ -1,5 +1,5 @@ import { lineString } from "@turf/helpers"; -import { centerMean } from "./index"; +import { centerMean } from "./index.js"; const line = lineString([ [0, 0], diff --git a/packages/turf-center-median/bench.ts b/packages/turf-center-median/bench.ts index d97ffa3ba6..8a1edccdf8 100644 --- a/packages/turf-center-median/bench.ts +++ b/packages/turf-center-median/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { randomPoint } from "@turf/random"; -import { centerMedian } from "./index"; +import { centerMedian } from "./index.js"; /** * Benchmark Results diff --git a/packages/turf-center-median/package.json b/packages/turf-center-median/package.json index 863a513e2c..fb0d7e0d9a 100644 --- a/packages/turf-center-median/package.json +++ b/packages/turf-center-median/package.json @@ -23,19 +23,19 @@ "turf", "center-median" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-center-median/test.ts b/packages/turf-center-median/test.ts index c2a3c63c49..3ae4d0ba87 100644 --- a/packages/turf-center-median/test.ts +++ b/packages/turf-center-median/test.ts @@ -1,6 +1,7 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { center } from "@turf/center"; @@ -8,7 +9,9 @@ import { truncate } from "@turf/truncate"; import { centerMean } from "@turf/center-mean"; import { centerOfMass } from "@turf/center-of-mass"; import { featureCollection, round } from "@turf/helpers"; -import { centerMedian } from "./index"; +import { centerMedian } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-center-median", (t) => { glob diff --git a/packages/turf-center-of-mass/bench.ts b/packages/turf-center-of-mass/bench.ts index 4701b5337d..ecb4e9665d 100644 --- a/packages/turf-center-of-mass/bench.ts +++ b/packages/turf-center-of-mass/bench.ts @@ -1,9 +1,12 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; import { centerOfMass } from "./index.js"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + const fixtures = glob .sync(path.join(__dirname, "test", "in", "*.geojson")) .map((input) => { diff --git a/packages/turf-center-of-mass/package.json b/packages/turf-center-of-mass/package.json index cffdb35d8e..944f354e1d 100644 --- a/packages/turf-center-of-mass/package.json +++ b/packages/turf-center-of-mass/package.json @@ -20,19 +20,19 @@ "turf", "gis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -47,7 +47,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-center-of-mass/test.ts b/packages/turf-center-of-mass/test.ts index 9c81be2492..915392c507 100644 --- a/packages/turf-center-of-mass/test.ts +++ b/packages/turf-center-of-mass/test.ts @@ -1,11 +1,14 @@ import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; import { point, lineString, polygon, featureCollection } from "@turf/helpers"; -import { centerOfMass } from "./index"; +import { centerOfMass } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-center-of-mass/types.ts b/packages/turf-center-of-mass/types.ts index 9617b058cf..773280c0b7 100644 --- a/packages/turf-center-of-mass/types.ts +++ b/packages/turf-center-of-mass/types.ts @@ -1,5 +1,5 @@ import { lineString } from "@turf/helpers"; -import { centerOfMass } from "./index"; +import { centerOfMass } from "./index.js"; const line = lineString([ [0, 0], diff --git a/packages/turf-center/bench.ts b/packages/turf-center/bench.ts index 1ab5c5a238..aed38d1999 100644 --- a/packages/turf-center/bench.ts +++ b/packages/turf-center/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { center } from "./index"; +import { center } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const fixtures = glob .sync(path.join(__dirname, "test", "in", "*.geojson")) diff --git a/packages/turf-center/package.json b/packages/turf-center/package.json index 75adf49beb..e3cb2ef3cc 100644 --- a/packages/turf-center/package.json +++ b/packages/turf-center/package.json @@ -24,19 +24,19 @@ "geo", "turf" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-center/test.ts b/packages/turf-center/test.ts index b6dec98ca8..2896523e40 100644 --- a/packages/turf-center/test.ts +++ b/packages/turf-center/test.ts @@ -1,13 +1,16 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { bboxPolygon } from "@turf/bbox-polygon"; import { bbox } from "@turf/bbox"; import { featureEach, coordEach } from "@turf/meta"; import { lineString, featureCollection } from "@turf/helpers"; -import { center } from "./index"; +import { center } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-center", (t) => { glob diff --git a/packages/turf-center/types.ts b/packages/turf-center/types.ts index 53767582ef..20e2e9a957 100644 --- a/packages/turf-center/types.ts +++ b/packages/turf-center/types.ts @@ -1,5 +1,5 @@ import { lineString } from "@turf/helpers"; -import { center } from "./index"; +import { center } from "./index.js"; const line = lineString([ [0, 0], diff --git a/packages/turf-centroid/bench.ts b/packages/turf-centroid/bench.ts index a6bfba2870..cd91f55f85 100644 --- a/packages/turf-centroid/bench.ts +++ b/packages/turf-centroid/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { centroid } from "./index"; +import { centroid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const fixtures = glob .sync(path.join(__dirname, "test", "in", "*.geojson")) diff --git a/packages/turf-centroid/package.json b/packages/turf-centroid/package.json index 556f9a405b..cf617d5c92 100644 --- a/packages/turf-centroid/package.json +++ b/packages/turf-centroid/package.json @@ -22,19 +22,19 @@ "geo", "gis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -49,7 +49,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-centroid/test.ts b/packages/turf-centroid/test.ts index 2539049592..467f33412c 100644 --- a/packages/turf-centroid/test.ts +++ b/packages/turf-centroid/test.ts @@ -1,11 +1,14 @@ import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; import { featureCollection, lineString } from "@turf/helpers"; -import { centroid } from "./index"; +import { centroid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-centroid/types.ts b/packages/turf-centroid/types.ts index d08694d6a5..37700d53ca 100644 --- a/packages/turf-centroid/types.ts +++ b/packages/turf-centroid/types.ts @@ -1,5 +1,5 @@ import { lineString } from "@turf/helpers"; -import { centroid } from "./index"; +import { centroid } from "./index.js"; const line = lineString([ [0, 0], diff --git a/packages/turf-circle/bench.ts b/packages/turf-circle/bench.ts index 9279af0d8b..fcf2518834 100644 --- a/packages/turf-circle/bench.ts +++ b/packages/turf-circle/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { circle } from "./index"; +import { circle } from "./index.js"; const center = [-75.0, 39.0]; const radius = 5; diff --git a/packages/turf-circle/package.json b/packages/turf-circle/package.json index 28c3aa6918..1618cba9c6 100644 --- a/packages/turf-circle/package.json +++ b/packages/turf-circle/package.json @@ -24,19 +24,19 @@ "miles", "km" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@placemarkio/check-geojson": "^0.1.12", diff --git a/packages/turf-circle/test.ts b/packages/turf-circle/test.ts index c3a2309b5f..433e55f3c2 100644 --- a/packages/turf-circle/test.ts +++ b/packages/turf-circle/test.ts @@ -1,12 +1,15 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureCollection } from "@turf/helpers"; import { check } from "@placemarkio/check-geojson"; -import { circle } from "./index"; +import { circle } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-circle/types.ts b/packages/turf-circle/types.ts index e7be40ff25..453fb9ae7f 100644 --- a/packages/turf-circle/types.ts +++ b/packages/turf-circle/types.ts @@ -1,5 +1,5 @@ import { point } from "@turf/helpers"; -import { circle } from "./index"; +import { circle } from "./index.js"; const center = point([-75.343, 39.984]); const units = "kilometers"; diff --git a/packages/turf-clean-coords/bench.ts b/packages/turf-clean-coords/bench.ts index 5dfbeb3d15..b567b4755a 100644 --- a/packages/turf-clean-coords/bench.ts +++ b/packages/turf-clean-coords/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { cleanCoords } from "./index"; +import { cleanCoords } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-clean-coords/package.json b/packages/turf-clean-coords/package.json index 08c35e5b1d..e3f8226fd7 100644 --- a/packages/turf-clean-coords/package.json +++ b/packages/turf-clean-coords/package.json @@ -24,19 +24,19 @@ "gis", "clean-coords" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-clean-coords/test.ts b/packages/turf-clean-coords/test.ts index 762faf6c3a..60f77f4cfd 100644 --- a/packages/turf-clean-coords/test.ts +++ b/packages/turf-clean-coords/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { truncate } from "@turf/truncate"; import { @@ -11,7 +12,9 @@ import { polygon, } from "@turf/helpers"; import { writeJsonFileSync } from "write-json-file"; -import { cleanCoords } from "./index"; +import { cleanCoords } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-clean-coords/types.ts b/packages/turf-clean-coords/types.ts index 92e86fde1b..b9037fa586 100644 --- a/packages/turf-clean-coords/types.ts +++ b/packages/turf-clean-coords/types.ts @@ -1,5 +1,5 @@ import { multiPoint } from "@turf/helpers"; -import { cleanCoords } from "./index"; +import { cleanCoords } from "./index.js"; // Fixtures const multiPt = multiPoint([ diff --git a/packages/turf-clone/bench.ts b/packages/turf-clone/bench.ts index 373eb713fb..403913d13e 100644 --- a/packages/turf-clone/bench.ts +++ b/packages/turf-clone/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { point, lineString, polygon, featureCollection } from "@turf/helpers"; -import { clone } from "./index"; +import { clone } from "./index.js"; const fixtures = [ point([0, 20]), diff --git a/packages/turf-clone/package.json b/packages/turf-clone/package.json index 3c0fa896cb..008a2d32ab 100644 --- a/packages/turf-clone/package.json +++ b/packages/turf-clone/package.json @@ -23,19 +23,19 @@ "turf", "clone" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -50,7 +50,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/meta": "workspace:^", diff --git a/packages/turf-clone/test.ts b/packages/turf-clone/test.ts index 563d184e0b..7e47d9ca04 100644 --- a/packages/turf-clone/test.ts +++ b/packages/turf-clone/test.ts @@ -7,7 +7,7 @@ import { geometryCollection, } from "@turf/helpers"; import { coordEach } from "@turf/meta"; -import { clone } from "./index"; +import { clone } from "./index.js"; test("turf-clone", (t) => { // Define Features diff --git a/packages/turf-clone/types.ts b/packages/turf-clone/types.ts index dd241a58c9..07e9831a6c 100644 --- a/packages/turf-clone/types.ts +++ b/packages/turf-clone/types.ts @@ -1,6 +1,6 @@ import { Feature, LineString, Point } from "geojson"; import { lineString, point } from "@turf/helpers"; -import { clone } from "./index"; +import { clone } from "./index.js"; const pt = point([0, 20]); const ptCloned: Feature = clone(pt); diff --git a/packages/turf-clusters-dbscan/bench.ts b/packages/turf-clusters-dbscan/bench.ts index 167b69deda..c964021533 100644 --- a/packages/turf-clusters-dbscan/bench.ts +++ b/packages/turf-clusters-dbscan/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { clustersDbscan } from "./index"; +import { clustersDbscan } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-clusters-dbscan/index.ts b/packages/turf-clusters-dbscan/index.ts index b307bb64ed..7ad8906200 100644 --- a/packages/turf-clusters-dbscan/index.ts +++ b/packages/turf-clusters-dbscan/index.ts @@ -2,8 +2,7 @@ import { GeoJsonProperties, FeatureCollection, Point } from "geojson"; import { clone } from "@turf/clone"; import { distance } from "@turf/distance"; import { degreesToRadians, lengthToDegrees, Units } from "@turf/helpers"; -// @ts-expect-error No types available for rbush. -import RBush from "rbush"; +import { rbush as RBush } from "./lib/rbush-export.js"; type Dbscan = "core" | "edge" | "noise"; type DbscanProps = GeoJsonProperties & { diff --git a/packages/turf-clusters-dbscan/lib/rbush-export.ts b/packages/turf-clusters-dbscan/lib/rbush-export.ts new file mode 100644 index 0000000000..49463b8ab5 --- /dev/null +++ b/packages/turf-clusters-dbscan/lib/rbush-export.ts @@ -0,0 +1,7 @@ +// Get around problems with moduleResolution node16 and some older libraries. +// Manifests as "This expression is not callable ... has no call signatures" +// https://stackoverflow.com/a/74709714 + +import lib from "rbush"; + +export const rbush = lib as unknown as typeof lib.default; diff --git a/packages/turf-clusters-dbscan/package.json b/packages/turf-clusters-dbscan/package.json index a22034a72f..c65cab05da 100644 --- a/packages/turf-clusters-dbscan/package.json +++ b/packages/turf-clusters-dbscan/package.json @@ -30,19 +30,19 @@ "density", "dbscan" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -57,12 +57,13 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/centroid": "workspace:^", "@turf/clusters": "workspace:^", "@types/benchmark": "^2.1.5", + "@types/rbush": "^3.0.2", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "chromatism": "^3.0.0", diff --git a/packages/turf-clusters-dbscan/test.ts b/packages/turf-clusters-dbscan/test.ts index 7a20ba3d45..cabcd66456 100644 --- a/packages/turf-clusters-dbscan/test.ts +++ b/packages/turf-clusters-dbscan/test.ts @@ -1,15 +1,18 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { centroid } from "@turf/centroid"; -import * as chromatism from "chromatism"; +import chromatism from "chromatism"; import concaveman from "concaveman"; import { point, polygon, featureCollection } from "@turf/helpers"; import { clusterReduce, clusterEach } from "@turf/clusters"; import { coordAll, featureEach } from "@turf/meta"; -import { clustersDbscan } from "./index"; +import { clustersDbscan } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-clusters-dbscan/types.ts b/packages/turf-clusters-dbscan/types.ts index 631a1aa8d3..0433d16097 100644 --- a/packages/turf-clusters-dbscan/types.ts +++ b/packages/turf-clusters-dbscan/types.ts @@ -1,5 +1,5 @@ import { featureCollection, point } from "@turf/helpers"; -import { clustersDbscan } from "./index"; +import { clustersDbscan } from "./index.js"; // Fixtures const points = featureCollection([point([0, 0]), point([2, 2])]); diff --git a/packages/turf-clusters-kmeans/bench.ts b/packages/turf-clusters-kmeans/bench.ts index 5f0f51569f..4162817cf3 100644 --- a/packages/turf-clusters-kmeans/bench.ts +++ b/packages/turf-clusters-kmeans/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { clustersKmeans } from "./index"; +import { clustersKmeans } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-clusters-kmeans/package.json b/packages/turf-clusters-kmeans/package.json index 075a796ac6..4616f83f88 100644 --- a/packages/turf-clusters-kmeans/package.json +++ b/packages/turf-clusters-kmeans/package.json @@ -29,19 +29,19 @@ "clustering", "k-means" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -56,7 +56,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/centroid": "workspace:^", diff --git a/packages/turf-clusters-kmeans/test.ts b/packages/turf-clusters-kmeans/test.ts index 7570233407..518b7b5ba0 100644 --- a/packages/turf-clusters-kmeans/test.ts +++ b/packages/turf-clusters-kmeans/test.ts @@ -1,15 +1,18 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { centroid } from "@turf/centroid"; -import * as chromatism from "chromatism"; +import chromatism from "chromatism"; import concaveman from "concaveman"; import { point, polygon, featureCollection } from "@turf/helpers"; import { clusterReduce, clusterEach } from "@turf/clusters"; import { coordAll, featureEach } from "@turf/meta"; -import { clustersKmeans } from "./index"; +import { clustersKmeans } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-clusters-kmeans/types.ts b/packages/turf-clusters-kmeans/types.ts index c9d6fee386..6e9a779171 100644 --- a/packages/turf-clusters-kmeans/types.ts +++ b/packages/turf-clusters-kmeans/types.ts @@ -1,5 +1,5 @@ import { featureCollection, point } from "@turf/helpers"; -import { clustersKmeans } from "./index"; +import { clustersKmeans } from "./index.js"; // Fixtures const points = featureCollection([point([0, 0]), point([2, 2])]); diff --git a/packages/turf-clusters/bench.ts b/packages/turf-clusters/bench.ts index bf3c384ed1..7b105c1c3b 100644 --- a/packages/turf-clusters/bench.ts +++ b/packages/turf-clusters/bench.ts @@ -8,7 +8,7 @@ import { filterProperties, applyFilter, createBins, -} from "./index"; +} from "./index.js"; const geojson = featureCollection([ point([0, 0], { cluster: 0 }), diff --git a/packages/turf-clusters/package.json b/packages/turf-clusters/package.json index 1a4ea9fd36..160f3aab8d 100644 --- a/packages/turf-clusters/package.json +++ b/packages/turf-clusters/package.json @@ -26,19 +26,19 @@ "clusters", "clustering" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-clusters/test.ts b/packages/turf-clusters/test.ts index 68625beadd..35cb5ab550 100644 --- a/packages/turf-clusters/test.ts +++ b/packages/turf-clusters/test.ts @@ -9,7 +9,7 @@ import { applyFilter, filterProperties, propertiesContainsFilter, -} from "./index"; +} from "./index.js"; const properties = { foo: "bar", cluster: 0 }; const geojson = featureCollection([ diff --git a/packages/turf-clusters/types.ts b/packages/turf-clusters/types.ts index 183ecb1d98..3af8b77f30 100644 --- a/packages/turf-clusters/types.ts +++ b/packages/turf-clusters/types.ts @@ -1,7 +1,7 @@ import { Point } from "geojson"; -import * as clusters from "./"; +import * as clusters from "./index.js"; import { featureCollection, point } from "@turf/helpers"; -import { getCluster, clusterEach, clusterReduce } from "./index"; +import { getCluster, clusterEach, clusterReduce } from "./index.js"; /** * Fixtures diff --git a/packages/turf-collect/bench.ts b/packages/turf-collect/bench.ts index b2b84b96ca..35e250ae32 100644 --- a/packages/turf-collect/bench.ts +++ b/packages/turf-collect/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { polygon, featureCollection, point } from "@turf/helpers"; -import { collect } from "./index"; +import { collect } from "./index.js"; var poly1 = polygon([ [ diff --git a/packages/turf-collect/index.ts b/packages/turf-collect/index.ts index d8b713adab..bde4e7c069 100644 --- a/packages/turf-collect/index.ts +++ b/packages/turf-collect/index.ts @@ -1,7 +1,7 @@ import { FeatureCollection, Polygon, Point } from "geojson"; import { bbox as turfbbox } from "@turf/bbox"; import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon"; -import rbush from "rbush"; +import { rbush } from "./lib/rbush-export.js"; interface Entry { minX: number; diff --git a/packages/turf-collect/lib/rbush-export.ts b/packages/turf-collect/lib/rbush-export.ts new file mode 100644 index 0000000000..49463b8ab5 --- /dev/null +++ b/packages/turf-collect/lib/rbush-export.ts @@ -0,0 +1,7 @@ +// Get around problems with moduleResolution node16 and some older libraries. +// Manifests as "This expression is not callable ... has no call signatures" +// https://stackoverflow.com/a/74709714 + +import lib from "rbush"; + +export const rbush = lib as unknown as typeof lib.default; diff --git a/packages/turf-collect/package.json b/packages/turf-collect/package.json index 1794471274..ef59d53e1a 100644 --- a/packages/turf-collect/package.json +++ b/packages/turf-collect/package.json @@ -27,19 +27,19 @@ "polygons", "stats" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-collect/test.ts b/packages/turf-collect/test.ts index e055f9aa6b..f2b2219700 100644 --- a/packages/turf-collect/test.ts +++ b/packages/turf-collect/test.ts @@ -1,6 +1,6 @@ import test from "tape"; import { featureCollection, point, polygon } from "@turf/helpers"; -import { collect } from "./index"; +import { collect } from "./index.js"; test("turf collect module", (t) => { const poly1 = polygon([ diff --git a/packages/turf-combine/bench.ts b/packages/turf-combine/bench.ts index 5e5cabb59f..458dbc6921 100644 --- a/packages/turf-combine/bench.ts +++ b/packages/turf-combine/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { point, polygon, lineString, featureCollection } from "@turf/helpers"; -import { combine } from "./index"; +import { combine } from "./index.js"; // MultiPoint var pt1 = point(50, 51); diff --git a/packages/turf-combine/package.json b/packages/turf-combine/package.json index e0a1241a5c..f56b637873 100644 --- a/packages/turf-combine/package.json +++ b/packages/turf-combine/package.json @@ -23,19 +23,19 @@ "multipolygon", "combine" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-combine/test.ts b/packages/turf-combine/test.ts index 6e3eac52fd..4e48683e12 100644 --- a/packages/turf-combine/test.ts +++ b/packages/turf-combine/test.ts @@ -8,7 +8,7 @@ import { multiLineString, featureCollection, } from "@turf/helpers"; -import { combine } from "./index"; +import { combine } from "./index.js"; test("combine -- points", (t) => { // MultiPoint diff --git a/packages/turf-concave/bench.ts b/packages/turf-concave/bench.ts index aeb64a6bab..82c505ec8f 100644 --- a/packages/turf-concave/bench.ts +++ b/packages/turf-concave/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { concave } from "./index"; +import { concave } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-concave/index.ts b/packages/turf-concave/index.ts index 2e18eff090..d0a87b5c50 100644 --- a/packages/turf-concave/index.ts +++ b/packages/turf-concave/index.ts @@ -10,7 +10,7 @@ import { import { Units } from "@turf/helpers"; import { featureEach } from "@turf/meta"; import { tin } from "@turf/tin"; -import { dissolve } from "./lib/turf-dissolve"; +import { dissolve } from "./lib/turf-dissolve.js"; /** * Takes a set of {@link Point|points} and returns a concave hull Polygon or MultiPolygon. diff --git a/packages/turf-concave/lib/turf-dissolve.ts b/packages/turf-concave/lib/turf-dissolve.ts index 8287ba2483..3973b1fbb1 100644 --- a/packages/turf-concave/lib/turf-dissolve.ts +++ b/packages/turf-concave/lib/turf-dissolve.ts @@ -10,8 +10,8 @@ import { clone } from "@turf/clone"; import { isObject } from "@turf/helpers"; import { getType } from "@turf/invariant"; import { flattenEach } from "@turf/meta"; -import { lineDissolve } from "./turf-line-dissolve"; -import { polygonDissolve } from "./turf-polygon-dissolve"; +import { lineDissolve } from "./turf-line-dissolve.js"; +import { polygonDissolve } from "./turf-polygon-dissolve.js"; /** * Transform function: attempts to dissolve geojson objects where possible diff --git a/packages/turf-concave/package.json b/packages/turf-concave/package.json index cb0c279b3c..3055ed15cf 100644 --- a/packages/turf-concave/package.json +++ b/packages/turf-concave/package.json @@ -33,19 +33,19 @@ "concave", "geometry" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-concave/test.ts b/packages/turf-concave/test.ts index 94555c4a5f..95d62e7de2 100644 --- a/packages/turf-concave/test.ts +++ b/packages/turf-concave/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point, featureCollection } from "@turf/helpers"; import { featureEach } from "@turf/meta"; -import { concave } from "./index"; +import { concave } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-convex/bench.ts b/packages/turf-convex/bench.ts index 3d404d92a3..e2dfbdd688 100644 --- a/packages/turf-convex/bench.ts +++ b/packages/turf-convex/bench.ts @@ -1,8 +1,11 @@ import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { convex } from "./index"; +import { convex } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const suite = new Benchmark.Suite("turf-convex"); diff --git a/packages/turf-convex/package.json b/packages/turf-convex/package.json index 5b193a7b24..750fae15c6 100644 --- a/packages/turf-convex/package.json +++ b/packages/turf-convex/package.json @@ -20,19 +20,19 @@ "turf", "gis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-convex/test.ts b/packages/turf-convex/test.ts index cef321ac66..58b0cde7c5 100644 --- a/packages/turf-convex/test.ts +++ b/packages/turf-convex/test.ts @@ -1,10 +1,13 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { writeJsonFileSync } from "write-json-file"; import { loadJsonFileSync } from "load-json-file"; import { featureCollection } from "@turf/helpers"; -import { convex } from "./index"; +import { convex } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-destination/bench.ts b/packages/turf-destination/bench.ts index 51551b9802..15c53fda71 100644 --- a/packages/turf-destination/bench.ts +++ b/packages/turf-destination/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { destination } from "./index"; +import { destination } from "./index.js"; var pt1 = [-75.0, 39.0]; var dist = 100; diff --git a/packages/turf-destination/package.json b/packages/turf-destination/package.json index bfcb46a456..8e3316a444 100644 --- a/packages/turf-destination/package.json +++ b/packages/turf-destination/package.json @@ -24,19 +24,19 @@ "miles", "km" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-destination/test.ts b/packages/turf-destination/test.ts index ed25493b09..1181591cab 100644 --- a/packages/turf-destination/test.ts +++ b/packages/turf-destination/test.ts @@ -1,4 +1,5 @@ import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; @@ -6,7 +7,9 @@ import { writeJsonFileSync } from "write-json-file"; import { getCoords } from "@turf/invariant"; import { lineString, featureCollection } from "@turf/helpers"; import { truncate } from "@turf/truncate"; -import { destination } from "./index"; +import { destination } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-difference/bench.ts b/packages/turf-difference/bench.ts index 08bb38e24d..1dd9755ccc 100644 --- a/packages/turf-difference/bench.ts +++ b/packages/turf-difference/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { difference } from "./index"; +import { difference } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-difference/package.json b/packages/turf-difference/package.json index c953f22493..1549708695 100644 --- a/packages/turf-difference/package.json +++ b/packages/turf-difference/package.json @@ -20,19 +20,19 @@ "turf", "gis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-difference/test.ts b/packages/turf-difference/test.ts index 91ed5b2a3c..d261d175c5 100644 --- a/packages/turf-difference/test.ts +++ b/packages/turf-difference/test.ts @@ -1,10 +1,13 @@ import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureCollection, polygon } from "@turf/helpers"; -import { difference } from "./index"; +import { difference } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-directional-mean/bench.ts b/packages/turf-directional-mean/bench.ts index 17598e6706..7d571d68ff 100644 --- a/packages/turf-directional-mean/bench.ts +++ b/packages/turf-directional-mean/bench.ts @@ -1,9 +1,12 @@ import Benchmark from "benchmark"; -import { directionalMean } from "./index"; +import { directionalMean } from "./index.js"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + /** * Benchmark Results * diff --git a/packages/turf-directional-mean/package.json b/packages/turf-directional-mean/package.json index 7259dcdd48..f13011df28 100644 --- a/packages/turf-directional-mean/package.json +++ b/packages/turf-directional-mean/package.json @@ -23,19 +23,19 @@ "turf", "directional-mean" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-directional-mean/test.ts b/packages/turf-directional-mean/test.ts index 50f6524156..2cff458654 100644 --- a/packages/turf-directional-mean/test.ts +++ b/packages/turf-directional-mean/test.ts @@ -1,8 +1,11 @@ import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import { directionalMean } from "./index"; +import { directionalMean } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-directional-mean", (t) => { const outGpsJsonPath1 = path.join( diff --git a/packages/turf-dissolve/bench.ts b/packages/turf-dissolve/bench.ts index a1a9c18a30..fed1a0ee61 100644 --- a/packages/turf-dissolve/bench.ts +++ b/packages/turf-dissolve/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { dissolve } from "./index"; +import { dissolve } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-dissolve/package.json b/packages/turf-dissolve/package.json index dd386c4e29..39cf412381 100644 --- a/packages/turf-dissolve/package.json +++ b/packages/turf-dissolve/package.json @@ -23,19 +23,19 @@ "geojson", "polygon" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-dissolve/test.ts b/packages/turf-dissolve/test.ts index 5788426f9e..93d5858d5e 100644 --- a/packages/turf-dissolve/test.ts +++ b/packages/turf-dissolve/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { polygon, point, featureCollection } from "@turf/helpers"; -import { dissolve } from "./index"; +import { dissolve } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const SKIP = []; diff --git a/packages/turf-distance-weight/bench.ts b/packages/turf-distance-weight/bench.ts index fd4d68227d..8b95598af3 100644 --- a/packages/turf-distance-weight/bench.ts +++ b/packages/turf-distance-weight/bench.ts @@ -1,7 +1,10 @@ import Benchmark from "benchmark"; -import { distanceWeight } from "./index"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; +import { distanceWeight } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-distance-weight/package.json b/packages/turf-distance-weight/package.json index ff7d342f49..68a5fab1c3 100644 --- a/packages/turf-distance-weight/package.json +++ b/packages/turf-distance-weight/package.json @@ -23,19 +23,19 @@ "turf", "distance-weight" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-distance-weight/test.ts b/packages/turf-distance-weight/test.ts index 8c7bb19aa8..3b55504c58 100644 --- a/packages/turf-distance-weight/test.ts +++ b/packages/turf-distance-weight/test.ts @@ -2,8 +2,11 @@ import { point } from "@turf/helpers"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; -import { distanceWeight, pNormDistance } from "./index"; +import { distanceWeight, pNormDistance } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("pNormDistance function", (t) => { t.equal(pNormDistance(point([2, 0]), point([0, 0]), 2), 2, "2-norm is ok"); diff --git a/packages/turf-distance/bench.ts b/packages/turf-distance/bench.ts index 4b33b74009..031eda4a49 100644 --- a/packages/turf-distance/bench.ts +++ b/packages/turf-distance/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { distance } from "./index"; +import { distance } from "./index.js"; var pt1 = [-75.4, 39.4]; var pt2 = [-75.534, 39.123]; diff --git a/packages/turf-distance/package.json b/packages/turf-distance/package.json index dc5ea3b606..4d3748e4b5 100644 --- a/packages/turf-distance/package.json +++ b/packages/turf-distance/package.json @@ -22,19 +22,19 @@ "miles", "km" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-distance/test.ts b/packages/turf-distance/test.ts index 88d2970a2b..25f57ef8c6 100644 --- a/packages/turf-distance/test.ts +++ b/packages/turf-distance/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point } from "@turf/helpers"; -import { distance } from "./index"; +import { distance } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-ellipse/bench.ts b/packages/turf-ellipse/bench.ts index 6dfb72780d..d6efa775b3 100644 --- a/packages/turf-ellipse/bench.ts +++ b/packages/turf-ellipse/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { ellipse } from "./index"; +import { ellipse } from "./index.js"; /** * Benchmark Results diff --git a/packages/turf-ellipse/package.json b/packages/turf-ellipse/package.json index 5f1344936f..a209de7ab1 100644 --- a/packages/turf-ellipse/package.json +++ b/packages/turf-ellipse/package.json @@ -23,19 +23,19 @@ "turf", "ellipse" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-ellipse/test.ts b/packages/turf-ellipse/test.ts index cbd2342154..62d2065333 100644 --- a/packages/turf-ellipse/test.ts +++ b/packages/turf-ellipse/test.ts @@ -1,6 +1,7 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { circle } from "@turf/circle"; @@ -10,7 +11,9 @@ import { bboxPolygon } from "@turf/bbox-polygon"; import { rhumbDestination } from "@turf/rhumb-destination"; // import { destination } from '@turf/destination'; import { featureCollection } from "@turf/helpers"; -import { ellipse } from "./index"; +import { ellipse } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-ellipse", (t) => { glob diff --git a/packages/turf-envelope/bench.ts b/packages/turf-envelope/bench.ts index 0442bcc0df..3fe9d3f9b4 100644 --- a/packages/turf-envelope/bench.ts +++ b/packages/turf-envelope/bench.ts @@ -1,7 +1,10 @@ import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { envelope } from "./index"; +import { envelope } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const fixture = loadJsonFileSync( path.join(__dirname, "test", "in", "feature-collection.geojson") diff --git a/packages/turf-envelope/package.json b/packages/turf-envelope/package.json index 8579f4b82b..49acf53534 100644 --- a/packages/turf-envelope/package.json +++ b/packages/turf-envelope/package.json @@ -23,19 +23,19 @@ "polygon", "extent" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-envelope/test.ts b/packages/turf-envelope/test.ts index 97280e5635..01dc71beec 100644 --- a/packages/turf-envelope/test.ts +++ b/packages/turf-envelope/test.ts @@ -1,7 +1,10 @@ import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; -import { envelope } from "./index"; +import { envelope } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Fixtures const fc = loadJsonFileSync( diff --git a/packages/turf-explode/bench.ts b/packages/turf-explode/bench.ts index 5c98b93fac..44cbac2a05 100644 --- a/packages/turf-explode/bench.ts +++ b/packages/turf-explode/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { polygon } from "@turf/helpers"; -import { explode } from "./index"; +import { explode } from "./index.js"; var poly = polygon([ [ diff --git a/packages/turf-explode/package.json b/packages/turf-explode/package.json index e19f1232cc..53e53a50c0 100644 --- a/packages/turf-explode/package.json +++ b/packages/turf-explode/package.json @@ -22,19 +22,19 @@ "geospatial", "coordinates" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-explode/test.ts b/packages/turf-explode/test.ts index c4df35e3df..5035895e8b 100644 --- a/packages/turf-explode/test.ts +++ b/packages/turf-explode/test.ts @@ -1,9 +1,12 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import tape from "tape"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import { explode } from "./index"; +import { explode } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-flatten/bench.ts b/packages/turf-flatten/bench.ts index 961eca9f42..60ff99d4be 100644 --- a/packages/turf-flatten/bench.ts +++ b/packages/turf-flatten/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { flatten } from "./index"; +import { flatten } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Define fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-flatten/package.json b/packages/turf-flatten/package.json index f706d75d42..c5ee3d8f43 100644 --- a/packages/turf-flatten/package.json +++ b/packages/turf-flatten/package.json @@ -27,19 +27,19 @@ "gis", "featurecollection" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-flatten/test.ts b/packages/turf-flatten/test.ts index 47933ee933..8241f22159 100644 --- a/packages/turf-flatten/test.ts +++ b/packages/turf-flatten/test.ts @@ -1,9 +1,12 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import { flatten } from "./index"; +import { flatten } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-flatten/types.ts b/packages/turf-flatten/types.ts index 0bb087121d..563b0945e8 100644 --- a/packages/turf-flatten/types.ts +++ b/packages/turf-flatten/types.ts @@ -5,7 +5,7 @@ import { geometryCollection, // Typescript types } from "@turf/helpers"; -import { flatten } from "./index"; +import { flatten } from "./index.js"; const multiPt = multiPoint([ [0, 0], diff --git a/packages/turf-flip/bench.ts b/packages/turf-flip/bench.ts index d1f77864d2..797b93337e 100644 --- a/packages/turf-flip/bench.ts +++ b/packages/turf-flip/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { flip } from "./index"; +import { flip } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-flip/package.json b/packages/turf-flip/package.json index b4d86c1569..e7df03145b 100644 --- a/packages/turf-flip/package.json +++ b/packages/turf-flip/package.json @@ -22,19 +22,19 @@ "coordinate", "flip" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -49,7 +49,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-flip/test.ts b/packages/turf-flip/test.ts index d4d4f2d45b..e299e81361 100644 --- a/packages/turf-flip/test.ts +++ b/packages/turf-flip/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point } from "@turf/helpers"; -import { flip } from "./index"; +import { flip } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-flip/types.ts b/packages/turf-flip/types.ts index f0029e79b9..c4543fe9c6 100644 --- a/packages/turf-flip/types.ts +++ b/packages/turf-flip/types.ts @@ -4,7 +4,7 @@ import { lineString, geometryCollection, } from "@turf/helpers"; -import { flip } from "./index"; +import { flip } from "./index.js"; const pt = point([120.1234567, 40.1234567]); const ptGeom = pt.geometry; diff --git a/packages/turf-geojson-rbush/bench.ts b/packages/turf-geojson-rbush/bench.ts index ce0893c4f8..ed363ae1ba 100644 --- a/packages/turf-geojson-rbush/bench.ts +++ b/packages/turf-geojson-rbush/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { randomPoint, randomPolygon } from "@turf/random"; -import { rbush as geojsonRbush } from "./index"; +import { geojsonRbush } from "./index.js"; // Fixtures const points = randomPoint(3); diff --git a/packages/turf-geojson-rbush/package.json b/packages/turf-geojson-rbush/package.json index 7246ad0a1f..f3cf09b008 100644 --- a/packages/turf-geojson-rbush/package.json +++ b/packages/turf-geojson-rbush/package.json @@ -28,27 +28,26 @@ "spatial", "rbush" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -56,11 +55,13 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", "@turf/random": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-geojson-rbush/test.ts b/packages/turf-geojson-rbush/test.ts index f1a2298b1c..c9a545bc05 100644 --- a/packages/turf-geojson-rbush/test.ts +++ b/packages/turf-geojson-rbush/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { bboxPolygon } from "@turf/bbox-polygon"; import { featureCollection, polygons } from "@turf/helpers"; -import { geojsonRbush } from "./index"; +import { geojsonRbush } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-geojson-rbush/types.ts b/packages/turf-geojson-rbush/types.ts index cc10b4636c..e094f03eed 100644 --- a/packages/turf-geojson-rbush/types.ts +++ b/packages/turf-geojson-rbush/types.ts @@ -1,6 +1,6 @@ import { point, polygon, featureCollection } from "@turf/helpers"; import { BBox, Point, Polygon } from "geojson"; -import { geojsonRbush as rbush } from "./"; +import { geojsonRbush as rbush } from "./index.js"; // Fixtures const bbox: BBox = [-180, -90, 180, 90]; diff --git a/packages/turf-great-circle/bench.ts b/packages/turf-great-circle/bench.ts index 19621bc7a8..8ca597d6a9 100644 --- a/packages/turf-great-circle/bench.ts +++ b/packages/turf-great-circle/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { point } from "@turf/helpers"; -import { greatCircle } from "./index"; +import { greatCircle } from "./index.js"; const point1 = point([-75, 45]); const point2 = point([30, 45]); diff --git a/packages/turf-great-circle/index.js b/packages/turf-great-circle/index.js index c8f53117df..8cbbeaeae9 100644 --- a/packages/turf-great-circle/index.js +++ b/packages/turf-great-circle/index.js @@ -1,5 +1,5 @@ import { getCoord } from "@turf/invariant"; -import { GreatCircle } from "./lib/arc"; +import { GreatCircle } from "./lib/arc.js"; /** * Calculate great circles routes as {@link LineString} or {@link MultiLineString}. diff --git a/packages/turf-great-circle/package.json b/packages/turf-great-circle/package.json index 61f33f9cda..96eea673d2 100644 --- a/packages/turf-great-circle/package.json +++ b/packages/turf-great-circle/package.json @@ -28,27 +28,26 @@ "great", "circle" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -56,10 +55,12 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-great-circle/test.ts b/packages/turf-great-circle/test.ts index ba94acb9bc..f5a1a3c3ae 100644 --- a/packages/turf-great-circle/test.ts +++ b/packages/turf-great-circle/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureCollection } from "@turf/helpers"; -import { greatCircle } from "./index"; +import { greatCircle } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-great-circle/types.ts b/packages/turf-great-circle/types.ts index 905287fd55..c12a7901c8 100644 --- a/packages/turf-great-circle/types.ts +++ b/packages/turf-great-circle/types.ts @@ -1,5 +1,5 @@ import { point } from "@turf/helpers"; -import { greatCircle } from "./index"; +import { greatCircle } from "./index.js"; const pt1 = point([0, 0]); const pt2 = point([60, 0]); diff --git a/packages/turf-helpers/bench.ts b/packages/turf-helpers/bench.ts index 3ef97544f5..93c48134c0 100644 --- a/packages/turf-helpers/bench.ts +++ b/packages/turf-helpers/bench.ts @@ -9,7 +9,7 @@ import { featureCollection, geometryCollection, round, -} from "./index"; +} from "./index.js"; /** * Benchmark Results diff --git a/packages/turf-helpers/index.ts b/packages/turf-helpers/index.ts index ba0693baa6..6b1c479834 100644 --- a/packages/turf-helpers/index.ts +++ b/packages/turf-helpers/index.ts @@ -15,9 +15,9 @@ import { GeoJsonProperties, } from "geojson"; -import { Id } from "./lib/geojson"; -export * from "./lib/geojson"; -export * from "./lib/geojson-equality"; +import { Id } from "./lib/geojson.js"; +export * from "./lib/geojson.js"; +export * from "./lib/geojson-equality.js"; // TurfJS Combined Types export type Coord = Feature | Point | Position; diff --git a/packages/turf-helpers/package.json b/packages/turf-helpers/package.json index 5f10215f94..fc4633331c 100644 --- a/packages/turf-helpers/package.json +++ b/packages/turf-helpers/package.json @@ -28,19 +28,19 @@ "turf", "geojson" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-helpers/test.ts b/packages/turf-helpers/test.ts index 8c687cf66c..7c912b8dc9 100644 --- a/packages/turf-helpers/test.ts +++ b/packages/turf-helpers/test.ts @@ -22,8 +22,8 @@ import { isNumber, earthRadius, GeojsonEquality, -} from "./index"; -import * as turf from "./index"; +} from "./index.js"; +import * as turf from "./index.js"; test("point", (t) => { const ptArray = point([5, 10], { name: "test point" }); diff --git a/packages/turf-helpers/types.ts b/packages/turf-helpers/types.ts index 74ae02a682..f414108041 100644 --- a/packages/turf-helpers/types.ts +++ b/packages/turf-helpers/types.ts @@ -16,7 +16,7 @@ import { point, polygon, radiansToLength, -} from "./"; +} from "./index.js"; // Fixtures const bbox: BBox = [-180, -90, 180, 90]; diff --git a/packages/turf-hex-grid/bench.ts b/packages/turf-hex-grid/bench.ts index 8ac452cba0..2fd783a73a 100644 --- a/packages/turf-hex-grid/bench.ts +++ b/packages/turf-hex-grid/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { hexGrid as grid } from "./index"; +import { hexGrid as grid } from "./index.js"; // prettier-ignore var bbox = [ diff --git a/packages/turf-hex-grid/package.json b/packages/turf-hex-grid/package.json index bc67901530..778f9a7426 100644 --- a/packages/turf-hex-grid/package.json +++ b/packages/turf-hex-grid/package.json @@ -32,19 +32,19 @@ "points", "geojson" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -59,7 +59,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-hex-grid/test.ts b/packages/turf-hex-grid/test.ts index 245b4033de..11a63210d0 100644 --- a/packages/turf-hex-grid/test.ts +++ b/packages/turf-hex-grid/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; -import { hexGrid } from "./index"; +import { hexGrid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, @@ -55,7 +58,7 @@ test("hex-grid", (t) => { }); test("grid tiles count", (t) => { - const bbox1 = require(directories.in + "bbox1.json").bbox; + const bbox1 = loadJsonFileSync(directories.in + "bbox1.json").bbox; t.equal(hexGrid(bbox1, 50, { units: "miles" }).features.length, 52); t.equal( hexGrid(bbox1, 50, { units: "miles", triangles: true }).features.length, @@ -66,7 +69,7 @@ test("grid tiles count", (t) => { }); test("Property mutation", (t) => { - const bbox1 = require(directories.in + "bbox1.json").bbox; + const bbox1 = loadJsonFileSync(directories.in + "bbox1.json").bbox; const grid = hexGrid(bbox1, 50, { units: "miles", properties: { foo: "bar" }, diff --git a/packages/turf-hex-grid/types.ts b/packages/turf-hex-grid/types.ts index 8b54a68fc0..1b07967130 100644 --- a/packages/turf-hex-grid/types.ts +++ b/packages/turf-hex-grid/types.ts @@ -1,5 +1,5 @@ import { BBox } from "geojson"; -import { hexGrid } from "./index"; +import { hexGrid } from "./index.js"; // prettier-ignore const bbox: BBox = [ diff --git a/packages/turf-interpolate/bench.ts b/packages/turf-interpolate/bench.ts index 85ce7f647e..8b981aa1fe 100644 --- a/packages/turf-interpolate/bench.ts +++ b/packages/turf-interpolate/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { interpolate } from "./index"; +import { interpolate } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-interpolate/package.json b/packages/turf-interpolate/package.json index f66c5ecc18..36a77495e7 100644 --- a/packages/turf-interpolate/package.json +++ b/packages/turf-interpolate/package.json @@ -24,27 +24,26 @@ "idw", "interpolate" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -52,10 +51,12 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "chromatism": "^3.0.0", "load-json-file": "^7.0.1", diff --git a/packages/turf-interpolate/test.ts b/packages/turf-interpolate/test.ts index 33ef0f28c2..3fb1b22c16 100644 --- a/packages/turf-interpolate/test.ts +++ b/packages/turf-interpolate/test.ts @@ -1,13 +1,16 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; -import { brightness } from "chromatism"; +import chromatism from "chromatism"; import { round, featureCollection, point } from "@turf/helpers"; import { featureEach, propEach } from "@turf/meta"; -import { interpolate } from "./index"; +import { interpolate } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, @@ -124,7 +127,7 @@ function colorize(grid, property, name) { const value = feature.properties[property]; const percent = round(((value - min - delta / 2) / delta) * 100); // darker corresponds to higher values - const color = brightness(-percent, "#0086FF").hex; + const color = chromatism.brightness(-percent, "#0086FF").hex; if (feature.geometry.type === "Point") feature.properties["marker-color"] = color; else { diff --git a/packages/turf-interpolate/types.ts b/packages/turf-interpolate/types.ts index 0ca2974b4d..61281353d5 100644 --- a/packages/turf-interpolate/types.ts +++ b/packages/turf-interpolate/types.ts @@ -1,5 +1,5 @@ import { point, featureCollection } from "@turf/helpers"; -import { interpolate } from "./index"; +import { interpolate } from "./index.js"; const cellSize = 1; const property = "pressure"; diff --git a/packages/turf-intersect/bench.ts b/packages/turf-intersect/bench.ts index 3005462775..17da77d649 100644 --- a/packages/turf-intersect/bench.ts +++ b/packages/turf-intersect/bench.ts @@ -1,7 +1,10 @@ import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { intersect } from "./index"; +import { intersect } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Fixtures const armenia = loadJsonFileSync( diff --git a/packages/turf-intersect/package.json b/packages/turf-intersect/package.json index c027e92650..c1f1b04ec7 100644 --- a/packages/turf-intersect/package.json +++ b/packages/turf-intersect/package.json @@ -21,19 +21,19 @@ "gis", "intersect" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -48,7 +48,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-intersect/test.ts b/packages/turf-intersect/test.ts index c283f32fe8..e1c16e84ab 100644 --- a/packages/turf-intersect/test.ts +++ b/packages/turf-intersect/test.ts @@ -1,10 +1,13 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureCollection } from "@turf/helpers"; -import { intersect } from "./index"; +import { intersect } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-intersect/types.ts b/packages/turf-intersect/types.ts index f8fb1e5bac..588c1800f1 100644 --- a/packages/turf-intersect/types.ts +++ b/packages/turf-intersect/types.ts @@ -1,5 +1,5 @@ import { featureCollection, polygon } from "@turf/helpers"; -import { intersect } from "./index"; +import { intersect } from "./index.js"; const poly1 = polygon([ [ diff --git a/packages/turf-invariant/bench.ts b/packages/turf-invariant/bench.ts index 8a8c18f951..17fb76f564 100644 --- a/packages/turf-invariant/bench.ts +++ b/packages/turf-invariant/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; -import { helpers } from "@turf/helpers"; -import * as invariant from "./index"; +import * as helpers from "@turf/helpers"; +import * as invariant from "./index.js"; const pt = helpers.point([-75, 40]); const line = helpers.lineString([ diff --git a/packages/turf-invariant/package.json b/packages/turf-invariant/package.json index f2e81868c1..96a07c6c37 100644 --- a/packages/turf-invariant/package.json +++ b/packages/turf-invariant/package.json @@ -25,19 +25,19 @@ "invariant", "expectations" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -52,7 +52,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-invariant/test.ts b/packages/turf-invariant/test.ts index ff5c8cd9ff..82e6af8894 100644 --- a/packages/turf-invariant/test.ts +++ b/packages/turf-invariant/test.ts @@ -6,7 +6,7 @@ import { featureCollection, geometryCollection, } from "@turf/helpers"; -import * as invariant from "./index"; +import * as invariant from "./index.js"; test("invariant -- containsNumber", (t) => { t.equals(invariant.containsNumber([1, 1]), true); diff --git a/packages/turf-invariant/types.ts b/packages/turf-invariant/types.ts index 388f1a876f..4b019b95f9 100644 --- a/packages/turf-invariant/types.ts +++ b/packages/turf-invariant/types.ts @@ -6,7 +6,7 @@ import { Polygon, Position, } from "geojson"; -import * as invariant from "./index"; +import * as invariant from "./index.js"; /** * Fixtures diff --git a/packages/turf-isobands/bench.ts b/packages/turf-isobands/bench.ts index 59ba00121c..43c05b5463 100644 --- a/packages/turf-isobands/bench.ts +++ b/packages/turf-isobands/bench.ts @@ -1,9 +1,12 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { matrixToGrid } from "./lib/matrix-to-grid"; -import { isobands } from "./index"; +import { matrixToGrid } from "./lib/matrix-to-grid.js"; +import { isobands } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-isobands/index.ts b/packages/turf-isobands/index.ts index 4b08d42de6..b03e2f26b0 100644 --- a/packages/turf-isobands/index.ts +++ b/packages/turf-isobands/index.ts @@ -20,7 +20,7 @@ import { Feature, } from "geojson"; -import { gridToMatrix } from "./lib/grid-to-matrix"; +import { gridToMatrix } from "./lib/grid-to-matrix.js"; import { isoBands } from "marchingsquares"; type GroupRingProps = { [prop: string]: string }; diff --git a/packages/turf-isobands/package.json b/packages/turf-isobands/package.json index caaad61e9b..9821faa231 100644 --- a/packages/turf-isobands/package.json +++ b/packages/turf-isobands/package.json @@ -28,19 +28,19 @@ "topography", "filled" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-isobands/test.ts b/packages/turf-isobands/test.ts index df45493164..5f9bdd17de 100644 --- a/packages/turf-isobands/test.ts +++ b/packages/turf-isobands/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { envelope } from "@turf/envelope"; @@ -9,8 +10,10 @@ import { truncate } from "@turf/truncate"; import { getCoords } from "@turf/invariant"; import { lineString } from "@turf/helpers"; import { randomPolygon } from "@turf/random"; -import { matrixToGrid } from "./lib/matrix-to-grid"; -import { isobands } from "./index"; +import { matrixToGrid } from "./lib/matrix-to-grid.js"; +import { isobands } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-isolines/bench.ts b/packages/turf-isolines/bench.ts index bdd3247c1c..d648e21a1d 100644 --- a/packages/turf-isolines/bench.ts +++ b/packages/turf-isolines/bench.ts @@ -1,9 +1,12 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { matrixToGrid } from "./lib/matrix-to-grid"; -import { isolines } from "./index"; +import { matrixToGrid } from "./lib/matrix-to-grid.js"; +import { isolines } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-isolines/index.ts b/packages/turf-isolines/index.ts index c10bf19b0a..bade82833a 100644 --- a/packages/turf-isolines/index.ts +++ b/packages/turf-isolines/index.ts @@ -4,7 +4,7 @@ import { collectionOf } from "@turf/invariant"; import { multiLineString, featureCollection, isObject } from "@turf/helpers"; // @ts-expect-error Legacy JS library with no types defined import { isoContours } from "marchingsquares"; -import { gridToMatrix } from "./lib/grid-to-matrix"; +import { gridToMatrix } from "./lib/grid-to-matrix.js"; import { FeatureCollection, Point, diff --git a/packages/turf-isolines/package.json b/packages/turf-isolines/package.json index 3605ddb5b1..7601fa5073 100644 --- a/packages/turf-isolines/package.json +++ b/packages/turf-isolines/package.json @@ -27,19 +27,19 @@ "elevation", "topography" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/envelope": "workspace:^", diff --git a/packages/turf-isolines/test.ts b/packages/turf-isolines/test.ts index ec234d2589..9bc3104c2d 100644 --- a/packages/turf-isolines/test.ts +++ b/packages/turf-isolines/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { envelope } from "@turf/envelope"; @@ -9,8 +10,10 @@ import { pointGrid } from "@turf/point-grid"; import { getCoords } from "@turf/invariant"; import { randomPolygon } from "@turf/random"; import { lineString } from "@turf/helpers"; -import { matrixToGrid } from "./lib/matrix-to-grid"; -import { isolines } from "./index"; +import { matrixToGrid } from "./lib/matrix-to-grid.js"; +import { isolines } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-isolines/types.ts b/packages/turf-isolines/types.ts index 24229374bc..94275d8c23 100644 --- a/packages/turf-isolines/types.ts +++ b/packages/turf-isolines/types.ts @@ -1,5 +1,5 @@ import { randomPoint } from "@turf/random"; -import { isolines } from "./index"; +import { isolines } from "./index.js"; const points = randomPoint(100, { bbox: [0, 30, 20, 50], diff --git a/packages/turf-kinks/bench.ts b/packages/turf-kinks/bench.ts index 2a5df0951b..39b057aaf9 100644 --- a/packages/turf-kinks/bench.ts +++ b/packages/turf-kinks/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { kinks } from "./index"; +import { kinks } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const suite = new Benchmark.Suite("turf-kinks"); diff --git a/packages/turf-kinks/index.ts b/packages/turf-kinks/index.ts index 9d6babbf4f..f8dcfb6c30 100644 --- a/packages/turf-kinks/index.ts +++ b/packages/turf-kinks/index.ts @@ -7,8 +7,8 @@ import { Point, Polygon, } from "geojson"; -import findIntersections from "sweepline-intersections"; import { point } from "@turf/helpers"; +import { sweeplineIntersections as findIntersections } from "./lib/sweepline-intersections-export.js"; /** * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring}, diff --git a/packages/turf-kinks/lib/sweepline-intersections-export.ts b/packages/turf-kinks/lib/sweepline-intersections-export.ts new file mode 100644 index 0000000000..2d10f64b69 --- /dev/null +++ b/packages/turf-kinks/lib/sweepline-intersections-export.ts @@ -0,0 +1,7 @@ +// Get around problems with moduleResolution node16 and some older libraries. +// Manifests as "This expression is not callable ... has no call signatures" +// https://stackoverflow.com/a/74709714 + +import lib from "sweepline-intersections"; + +export const sweeplineIntersections = lib as unknown as typeof lib.default; diff --git a/packages/turf-kinks/package.json b/packages/turf-kinks/package.json index f5de3dfc25..a3c3876a38 100644 --- a/packages/turf-kinks/package.json +++ b/packages/turf-kinks/package.json @@ -21,19 +21,19 @@ "kinks", "self-intersection" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -48,7 +48,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/meta": "workspace:^", diff --git a/packages/turf-kinks/test.ts b/packages/turf-kinks/test.ts index 12b44c1642..88466edb58 100644 --- a/packages/turf-kinks/test.ts +++ b/packages/turf-kinks/test.ts @@ -1,10 +1,13 @@ import test from "tape"; import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; -import { kinks } from "./index"; +import { kinks } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-kinks/types.ts b/packages/turf-kinks/types.ts index d591fc1121..105060ec0f 100644 --- a/packages/turf-kinks/types.ts +++ b/packages/turf-kinks/types.ts @@ -1,5 +1,5 @@ import { polygon } from "@turf/helpers"; -import { kinks } from "./index"; +import { kinks } from "./index.js"; const hourglass = polygon([ [ diff --git a/packages/turf-length/bench.ts b/packages/turf-length/bench.ts index c2fef085fe..71721ef1c1 100644 --- a/packages/turf-length/bench.ts +++ b/packages/turf-length/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { length } from "./index"; +import { length } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Define fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-length/package.json b/packages/turf-length/package.json index 551669f3db..4353b5d7e1 100644 --- a/packages/turf-length/package.json +++ b/packages/turf-length/package.json @@ -28,19 +28,19 @@ "units", "gis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-length/test.ts b/packages/turf-length/test.ts index e5208b144e..cf559c5f94 100644 --- a/packages/turf-length/test.ts +++ b/packages/turf-length/test.ts @@ -1,9 +1,12 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import { length } from "./index"; +import { length } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-arc/bench.ts b/packages/turf-line-arc/bench.ts index f64d18da5c..a5d18e416f 100644 --- a/packages/turf-line-arc/bench.ts +++ b/packages/turf-line-arc/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { lineArc } from "./index"; +import { lineArc } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-arc/package.json b/packages/turf-line-arc/package.json index 6ad0974ce3..b3e3edfc9d 100644 --- a/packages/turf-line-arc/package.json +++ b/packages/turf-line-arc/package.json @@ -20,19 +20,19 @@ "turf", "gif" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -47,7 +47,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-line-arc/test.ts b/packages/turf-line-arc/test.ts index 68e5e1a52f..0706b079d0 100644 --- a/packages/turf-line-arc/test.ts +++ b/packages/turf-line-arc/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureCollection, point } from "@turf/helpers"; -import { lineArc } from "./index"; +import { lineArc } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-arc/types.ts b/packages/turf-line-arc/types.ts index 4caa09daad..8a82bb3473 100644 --- a/packages/turf-line-arc/types.ts +++ b/packages/turf-line-arc/types.ts @@ -1,5 +1,5 @@ import { point } from "@turf/helpers"; -import { lineArc } from "./index"; +import { lineArc } from "./index.js"; const center = point([-75.343, 39.984]); const bearing1 = 10; diff --git a/packages/turf-line-chunk/bench.ts b/packages/turf-line-chunk/bench.ts index 4f014f16ec..adca31fab2 100644 --- a/packages/turf-line-chunk/bench.ts +++ b/packages/turf-line-chunk/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { lineChunk } from "./index"; +import { lineChunk } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-chunk/package.json b/packages/turf-line-chunk/package.json index 38f79bdbbc..8640a383b2 100644 --- a/packages/turf-line-chunk/package.json +++ b/packages/turf-line-chunk/package.json @@ -29,27 +29,26 @@ "linestring", "line segment" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -57,10 +56,12 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-line-chunk/test.ts b/packages/turf-line-chunk/test.ts index 38852774b0..8ec0d013ae 100644 --- a/packages/turf-line-chunk/test.ts +++ b/packages/turf-line-chunk/test.ts @@ -1,12 +1,15 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureEach } from "@turf/meta"; import { lineString, featureCollection } from "@turf/helpers"; -import { lineChunk } from "./index"; +import { lineChunk } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-chunk/types.ts b/packages/turf-line-chunk/types.ts index fdc0b6fe53..fbd45b54aa 100644 --- a/packages/turf-line-chunk/types.ts +++ b/packages/turf-line-chunk/types.ts @@ -3,7 +3,7 @@ import { geometryCollection, featureCollection, } from "@turf/helpers"; -import { lineChunk } from "./index"; +import { lineChunk } from "./index.js"; const line = lineString([ [0, 0], diff --git a/packages/turf-line-intersect/bench.ts b/packages/turf-line-intersect/bench.ts index 071055a6bf..81b7d43569 100644 --- a/packages/turf-line-intersect/bench.ts +++ b/packages/turf-line-intersect/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { lineIntersect } from "./index"; +import { lineIntersect } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index 351a9fb6d8..e4c83d30ed 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -8,7 +8,8 @@ import { Point, Polygon, } from "geojson"; -import findIntersections, { Intersection } from "sweepline-intersections"; +import type { Intersection } from "sweepline-intersections"; +import { sweeplineIntersections as findIntersections } from "./lib/sweepline-intersections-export.js"; /** * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). diff --git a/packages/turf-line-intersect/lib/sweepline-intersections-export.ts b/packages/turf-line-intersect/lib/sweepline-intersections-export.ts new file mode 100644 index 0000000000..2d10f64b69 --- /dev/null +++ b/packages/turf-line-intersect/lib/sweepline-intersections-export.ts @@ -0,0 +1,7 @@ +// Get around problems with moduleResolution node16 and some older libraries. +// Manifests as "This expression is not callable ... has no call signatures" +// https://stackoverflow.com/a/74709714 + +import lib from "sweepline-intersections"; + +export const sweeplineIntersections = lib as unknown as typeof lib.default; diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index 5982947b34..3bbacc2c5e 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -27,19 +27,19 @@ "line", "intersect" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-line-intersect/test.ts b/packages/turf-line-intersect/test.ts index c04d0d2c53..40d45e91db 100644 --- a/packages/turf-line-intersect/test.ts +++ b/packages/turf-line-intersect/test.ts @@ -10,11 +10,11 @@ import { lineString, polygon, } from "@turf/helpers"; -import { lineIntersect } from "./index"; +import { lineIntersect } from "./index.js"; const directories = { - in: path.join(__dirname, "test", "in") + path.sep, - out: path.join(__dirname, "test", "out") + path.sep, + in: path.join("test", "in") + path.sep, + out: path.join("test", "out") + path.sep, }; const fixtures = fs.readdirSync(directories.in).map((filename) => { diff --git a/packages/turf-line-offset/bench.ts b/packages/turf-line-offset/bench.ts index 5a5efabf42..4039a0f001 100644 --- a/packages/turf-line-offset/bench.ts +++ b/packages/turf-line-offset/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { lineOffset } from "./index"; +import { lineOffset } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-offset/index.js b/packages/turf-line-offset/index.js index 0ac0a307f4..1c936c4b21 100644 --- a/packages/turf-line-offset/index.js +++ b/packages/turf-line-offset/index.js @@ -6,7 +6,7 @@ import { multiLineString, lengthToDegrees, } from "@turf/helpers"; -import { intersection } from "./lib/intersection"; +import { intersection } from "./lib/intersection.js"; /** * Takes a {@link LineString|line} and returns a {@link LineString|line} at offset by the specified distance. diff --git a/packages/turf-line-offset/package.json b/packages/turf-line-offset/package.json index 2b1a454d14..8c7a8f50f6 100644 --- a/packages/turf-line-offset/package.json +++ b/packages/turf-line-offset/package.json @@ -27,27 +27,26 @@ "turf", "offset" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -55,10 +54,12 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-line-offset/test.ts b/packages/turf-line-offset/test.ts index d13755d16e..6efcfa7638 100644 --- a/packages/turf-line-offset/test.ts +++ b/packages/turf-line-offset/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureCollection, lineString } from "@turf/helpers"; -import { lineOffset } from "./index"; +import { lineOffset } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-offset/types.ts b/packages/turf-line-offset/types.ts index 401cb68e0b..43789bcaa3 100644 --- a/packages/turf-line-offset/types.ts +++ b/packages/turf-line-offset/types.ts @@ -1,4 +1,4 @@ -import { lineOffset } from "./index"; +import { lineOffset } from "./index.js"; import { lineString, multiLineString } from "@turf/helpers"; const line = lineString([ diff --git a/packages/turf-line-overlap/bench.ts b/packages/turf-line-overlap/bench.ts index 378b5a1b15..e706bcc3ee 100644 --- a/packages/turf-line-overlap/bench.ts +++ b/packages/turf-line-overlap/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { lineOverlap } from "./index"; +import { lineOverlap } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-overlap/package.json b/packages/turf-line-overlap/package.json index d30cef72d6..6e5ebec0ad 100644 --- a/packages/turf-line-overlap/package.json +++ b/packages/turf-line-overlap/package.json @@ -26,19 +26,19 @@ "line", "overlap" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-line-overlap/test.ts b/packages/turf-line-overlap/test.ts index c120a83a6a..ea654935f8 100644 --- a/packages/turf-line-overlap/test.ts +++ b/packages/turf-line-overlap/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; import { featureCollection, lineString } from "@turf/helpers"; -import { lineOverlap } from "./index"; +import { lineOverlap } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-overlap/types.ts b/packages/turf-line-overlap/types.ts index 8f71d06394..9b1f420234 100644 --- a/packages/turf-line-overlap/types.ts +++ b/packages/turf-line-overlap/types.ts @@ -4,7 +4,7 @@ import { polygon, multiPolygon, } from "@turf/helpers"; -import { lineOverlap } from "./index"; +import { lineOverlap } from "./index.js"; const line = lineString([ [0, 0], diff --git a/packages/turf-line-segment/bench.ts b/packages/turf-line-segment/bench.ts index a2f0dbec3e..b9c8a568e4 100644 --- a/packages/turf-line-segment/bench.ts +++ b/packages/turf-line-segment/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { lineSegment } from "./index"; +import { lineSegment } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-line-segment/package.json b/packages/turf-line-segment/package.json index 0aafd7a5f4..b39234ba16 100644 --- a/packages/turf-line-segment/package.json +++ b/packages/turf-line-segment/package.json @@ -21,19 +21,19 @@ "line", "segment" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-line-segment/test.ts b/packages/turf-line-segment/test.ts index 1da32aa0e1..765954d51f 100644 --- a/packages/turf-line-segment/test.ts +++ b/packages/turf-line-segment/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; import { featureCollection, lineString } from "@turf/helpers"; -import { lineSegment } from "./index"; +import { lineSegment } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-slice-along/bench.ts b/packages/turf-line-slice-along/bench.ts index 0e42449811..b10c7b0916 100644 --- a/packages/turf-line-slice-along/bench.ts +++ b/packages/turf-line-slice-along/bench.ts @@ -1,6 +1,10 @@ import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; import Benchmark from "benchmark"; -import { lineSliceAlong } from "./index"; +import { lineSliceAlong } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); var line1 = JSON.parse( fs.readFileSync(__dirname + "/test/fixtures/line1.geojson") diff --git a/packages/turf-line-slice-along/package.json b/packages/turf-line-slice-along/package.json index 6b8cd6155e..91371e0861 100644 --- a/packages/turf-line-slice-along/package.json +++ b/packages/turf-line-slice-along/package.json @@ -21,27 +21,26 @@ "along", "line-slice" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -53,6 +52,8 @@ "devDependencies": { "@turf/along": "workspace:^", "@turf/length": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-line-slice-along/test.ts b/packages/turf-line-slice-along/test.ts index a5c7db2043..196c3a4820 100644 --- a/packages/turf-line-slice-along/test.ts +++ b/packages/turf-line-slice-along/test.ts @@ -1,9 +1,12 @@ import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { along } from "@turf/along"; import { length } from "@turf/length"; -import { lineSliceAlong } from "./index"; +import { lineSliceAlong } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); var line1 = loadJsonFileSync( path.join(__dirname, "test", "fixtures", "line1.geojson") diff --git a/packages/turf-line-slice/bench.ts b/packages/turf-line-slice/bench.ts index 629eb3a432..133539d98a 100644 --- a/packages/turf-line-slice/bench.ts +++ b/packages/turf-line-slice/bench.ts @@ -1,7 +1,11 @@ import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; import Benchmark from "benchmark"; import { point } from "@turf/helpers"; -import { lineSlice } from "./index"; +import { lineSlice } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); var route1 = JSON.parse(fs.readFileSync(__dirname + "/test/in/route1.geojson")); var route2 = JSON.parse(fs.readFileSync(__dirname + "/test/in/route2.geojson")); diff --git a/packages/turf-line-slice/package.json b/packages/turf-line-slice/package.json index d045e42612..11d81d65fc 100644 --- a/packages/turf-line-slice/package.json +++ b/packages/turf-line-slice/package.json @@ -25,27 +25,26 @@ "line", "distance" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -56,6 +55,8 @@ }, "devDependencies": { "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-line-slice/test.ts b/packages/turf-line-slice/test.ts index 1583a6eaee..026b30238b 100644 --- a/packages/turf-line-slice/test.ts +++ b/packages/turf-line-slice/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureCollection } from "@turf/helpers"; -import { lineSlice } from "./index"; +import { lineSlice } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-split/bench.ts b/packages/turf-line-split/bench.ts index d6dd4ca85c..853bc118aa 100644 --- a/packages/turf-line-split/bench.ts +++ b/packages/turf-line-split/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { lineSplit } from "./index"; +import { lineSplit } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-split/package.json b/packages/turf-line-split/package.json index 4093782eff..d3f2003345 100644 --- a/packages/turf-line-split/package.json +++ b/packages/turf-line-split/package.json @@ -26,27 +26,26 @@ "line", "split" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -56,6 +55,8 @@ "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-line-split/test.ts b/packages/turf-line-split/test.ts index 2191b6326c..0b25ee534f 100644 --- a/packages/turf-line-split/test.ts +++ b/packages/turf-line-split/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; @@ -12,7 +13,9 @@ import { round, } from "@turf/helpers"; import { getCoords } from "@turf/invariant"; -import { lineSplit } from "./index"; +import { lineSplit } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-to-polygon/bench.ts b/packages/turf-line-to-polygon/bench.ts index ddf5960832..f1e25fe921 100644 --- a/packages/turf-line-to-polygon/bench.ts +++ b/packages/turf-line-to-polygon/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { lineToPolygon } from "./index"; +import { lineToPolygon } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-to-polygon/package.json b/packages/turf-line-to-polygon/package.json index 658e8e4e86..372d91e6c4 100644 --- a/packages/turf-line-to-polygon/package.json +++ b/packages/turf-line-to-polygon/package.json @@ -26,19 +26,19 @@ "linestring", "line" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-line-to-polygon/test.ts b/packages/turf-line-to-polygon/test.ts index d69b779a14..4ded0d079e 100644 --- a/packages/turf-line-to-polygon/test.ts +++ b/packages/turf-line-to-polygon/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point, lineString } from "@turf/helpers"; import { clone } from "@turf/clone"; -import { lineToPolygon } from "./index"; +import { lineToPolygon } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-to-polygon/types.ts b/packages/turf-line-to-polygon/types.ts index c551b5a1bd..6cd6193272 100644 --- a/packages/turf-line-to-polygon/types.ts +++ b/packages/turf-line-to-polygon/types.ts @@ -1,6 +1,6 @@ import { LineString, MultiLineString } from "geojson"; import { featureCollection, lineString, multiLineString } from "@turf/helpers"; -import { lineToPolygon } from "./index"; +import { lineToPolygon } from "./index.js"; // Fixtures const coords = [ diff --git a/packages/turf-mask/bench.ts b/packages/turf-mask/bench.ts index 57fe344266..7d56ab92a2 100644 --- a/packages/turf-mask/bench.ts +++ b/packages/turf-mask/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { mask as turfMask } from "./index"; +import { mask as turfMask } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const suite = new Benchmark.Suite("turf-mask"); diff --git a/packages/turf-mask/package.json b/packages/turf-mask/package.json index 67e4fde201..73d4717525 100644 --- a/packages/turf-mask/package.json +++ b/packages/turf-mask/package.json @@ -21,27 +21,26 @@ "mask", "polygon" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -49,9 +48,11 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "mkdirp": "^3.0.1", diff --git a/packages/turf-mask/test.ts b/packages/turf-mask/test.ts index 753593e749..a9f893f299 100644 --- a/packages/turf-mask/test.ts +++ b/packages/turf-mask/test.ts @@ -1,9 +1,12 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import { mask } from "./index"; +import { mask } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const SKIP = ["multi-polygon.geojson", "overlapping.geojson"]; diff --git a/packages/turf-mask/types.ts b/packages/turf-mask/types.ts index 3104a84d0a..151727711a 100644 --- a/packages/turf-mask/types.ts +++ b/packages/turf-mask/types.ts @@ -1,5 +1,5 @@ import { polygon } from "@turf/helpers"; -import { mask } from "./index"; +import { mask } from "./index.js"; const poly1 = polygon([ [ diff --git a/packages/turf-meta/bench.ts b/packages/turf-meta/bench.ts index c1f393cd4b..6601726853 100644 --- a/packages/turf-meta/bench.ts +++ b/packages/turf-meta/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import * as random from "@turf/random"; -import * as meta from "./index"; +import * as meta from "./index.js"; const fixtures = { point: random.randomPoint(), diff --git a/packages/turf-meta/package.json b/packages/turf-meta/package.json index 74fafdec94..d5cb99c0e1 100644 --- a/packages/turf-meta/package.json +++ b/packages/turf-meta/package.json @@ -43,27 +43,26 @@ "lineEeach", "lineReduce" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -71,10 +70,11 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/random": "workspace:^", + "@types/benchmark": "^2.1.5", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", "tape": "^5.7.2", diff --git a/packages/turf-meta/test.ts b/packages/turf-meta/test.ts index a5c8e27676..a8589fe0e3 100644 --- a/packages/turf-meta/test.ts +++ b/packages/turf-meta/test.ts @@ -11,7 +11,7 @@ import { featureCollection, lineStrings, } from "@turf/helpers"; -import * as meta from "./index"; +import * as meta from "./index.js"; const pt = point([0, 0], { a: 1 }); const pt2 = point([1, 1]); diff --git a/packages/turf-meta/types.ts b/packages/turf-meta/types.ts index 98582471bd..cd2e3a04ba 100644 --- a/packages/turf-meta/types.ts +++ b/packages/turf-meta/types.ts @@ -1,7 +1,7 @@ import { Point, LineString } from "geojson"; import * as helpers from "@turf/helpers"; import { featureCollection, point, lineString } from "@turf/helpers"; -import * as meta from "./"; +import * as meta from "./index.js"; import { coordReduce, coordEach, @@ -18,7 +18,7 @@ import { segmentEach, lineReduce, lineEach, -} from "./"; +} from "./index.js"; // Fixtures const pt = helpers.point([0, 0]); diff --git a/packages/turf-midpoint/bench.ts b/packages/turf-midpoint/bench.ts index 1a854af226..241f3f3998 100644 --- a/packages/turf-midpoint/bench.ts +++ b/packages/turf-midpoint/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { point } from "@turf/helpers"; -import { midpoint } from "./index"; +import { midpoint } from "./index.js"; var pt1 = point([0, 0]); var pt2 = point([10, 0]); diff --git a/packages/turf-midpoint/package.json b/packages/turf-midpoint/package.json index 320d0bfbf5..26fdef545a 100644 --- a/packages/turf-midpoint/package.json +++ b/packages/turf-midpoint/package.json @@ -23,27 +23,26 @@ "geojson", "line" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -53,6 +52,7 @@ "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", "tape": "^5.7.2", diff --git a/packages/turf-midpoint/test.ts b/packages/turf-midpoint/test.ts index ac79e4eb6d..a55881ec30 100644 --- a/packages/turf-midpoint/test.ts +++ b/packages/turf-midpoint/test.ts @@ -1,5 +1,5 @@ import test from "tape"; -import { midpoint } from "./index"; +import { midpoint } from "./index.js"; import { distance } from "@turf/distance"; import { point } from "@turf/helpers"; diff --git a/packages/turf-moran-index/bench.ts b/packages/turf-moran-index/bench.ts index 9fe3949f92..3c5b5664be 100644 --- a/packages/turf-moran-index/bench.ts +++ b/packages/turf-moran-index/bench.ts @@ -1,8 +1,11 @@ import Benchmark from "benchmark"; -import { moranIndex } from "./index"; +import { moranIndex } from "./index.js"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + /** * Benchmark Results * diff --git a/packages/turf-moran-index/package.json b/packages/turf-moran-index/package.json index fc1909d3dd..f9a2c0070d 100644 --- a/packages/turf-moran-index/package.json +++ b/packages/turf-moran-index/package.json @@ -23,19 +23,19 @@ "turf", "moran-index" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-moran-index/test.ts b/packages/turf-moran-index/test.ts index 74b64a78b1..c76b26b8b6 100644 --- a/packages/turf-moran-index/test.ts +++ b/packages/turf-moran-index/test.ts @@ -1,7 +1,10 @@ import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; -import { moranIndex } from "./index"; +import { moranIndex } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-moran-index", (t) => { const pointPath = path.join(__dirname, "test", "in", "point.json"); diff --git a/packages/turf-nearest-neighbor-analysis/bench.ts b/packages/turf-nearest-neighbor-analysis/bench.ts index 596d3fba51..0a6957d526 100644 --- a/packages/turf-nearest-neighbor-analysis/bench.ts +++ b/packages/turf-nearest-neighbor-analysis/bench.ts @@ -1,8 +1,11 @@ import Benchmark from "benchmark"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; -import { nearestNeighborAnalysis } from "./index"; +import { nearestNeighborAnalysis } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-nearest-neighbor-analysis/package.json b/packages/turf-nearest-neighbor-analysis/package.json index 7374e5139e..10f693d281 100644 --- a/packages/turf-nearest-neighbor-analysis/package.json +++ b/packages/turf-nearest-neighbor-analysis/package.json @@ -23,19 +23,19 @@ "turf", "nearest-neighbor" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-nearest-neighbor-analysis/test.ts b/packages/turf-nearest-neighbor-analysis/test.ts index 115335e3c2..b0009b77bb 100644 --- a/packages/turf-nearest-neighbor-analysis/test.ts +++ b/packages/turf-nearest-neighbor-analysis/test.ts @@ -1,13 +1,16 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { centroid } from "@turf/centroid"; import { featureEach } from "@turf/meta"; import { featureCollection } from "@turf/helpers"; -import { nearestNeighborAnalysis } from "./index"; +import { nearestNeighborAnalysis } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-nearest-point-on-line/bench.ts b/packages/turf-nearest-point-on-line/bench.ts index 54b5a757ab..c6e79eabf3 100644 --- a/packages/turf-nearest-point-on-line/bench.ts +++ b/packages/turf-nearest-point-on-line/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { nearestPointOnLine } from "./index"; +import { nearestPointOnLine } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-nearest-point-on-line/package.json b/packages/turf-nearest-point-on-line/package.json index cf69161a51..7d288326a1 100644 --- a/packages/turf-nearest-point-on-line/package.json +++ b/packages/turf-nearest-point-on-line/package.json @@ -16,18 +16,19 @@ "publishConfig": { "access": "public" }, + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -42,7 +43,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/along": "workspace:^", diff --git a/packages/turf-nearest-point-on-line/test.ts b/packages/turf-nearest-point-on-line/test.ts index 1270138381..ab0218fb6f 100644 --- a/packages/turf-nearest-point-on-line/test.ts +++ b/packages/turf-nearest-point-on-line/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { along } from "@turf/along"; @@ -14,7 +15,9 @@ import { featureCollection, round, } from "@turf/helpers"; -import { nearestPointOnLine } from "./index"; +import { nearestPointOnLine } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-nearest-point-on-line/types.ts b/packages/turf-nearest-point-on-line/types.ts index 86cdf7818a..03c988e94b 100644 --- a/packages/turf-nearest-point-on-line/types.ts +++ b/packages/turf-nearest-point-on-line/types.ts @@ -1,4 +1,4 @@ -import { nearestPointOnLine } from "./index"; +import { nearestPointOnLine } from "./index.js"; import { point, lineString, multiLineString } from "@turf/helpers"; const pt = point([1.5, 1.5]); diff --git a/packages/turf-nearest-point-to-line/bench.ts b/packages/turf-nearest-point-to-line/bench.ts index 9b898687e8..73a9348fda 100644 --- a/packages/turf-nearest-point-to-line/bench.ts +++ b/packages/turf-nearest-point-to-line/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { nearestPointToLine } from "./index"; +import { nearestPointToLine } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-nearest-point-to-line/package.json b/packages/turf-nearest-point-to-line/package.json index 2d616430ea..25d525d625 100644 --- a/packages/turf-nearest-point-to-line/package.json +++ b/packages/turf-nearest-point-to-line/package.json @@ -26,19 +26,19 @@ "near", "nearest-point-to-line" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/circle": "workspace:^", diff --git a/packages/turf-nearest-point-to-line/test.ts b/packages/turf-nearest-point-to-line/test.ts index f7f2185e87..4df9e7ec1c 100644 --- a/packages/turf-nearest-point-to-line/test.ts +++ b/packages/turf-nearest-point-to-line/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { circle } from "@turf/circle"; @@ -12,7 +13,9 @@ import { lineString, round, } from "@turf/helpers"; -import { nearestPointToLine } from "./index"; +import { nearestPointToLine } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-nearest-point-to-line/types.ts b/packages/turf-nearest-point-to-line/types.ts index 0cc2a76e8c..aca829901d 100644 --- a/packages/turf-nearest-point-to-line/types.ts +++ b/packages/turf-nearest-point-to-line/types.ts @@ -4,7 +4,7 @@ import { point, lineString, } from "@turf/helpers"; -import { nearestPointToLine } from "./index"; +import { nearestPointToLine } from "./index.js"; const points = featureCollection([point([0, 0]), point([0.5, 0.5])]); const line = lineString([ diff --git a/packages/turf-nearest-point/bench.ts b/packages/turf-nearest-point/bench.ts index 7b4d3b41b3..16346c74bc 100644 --- a/packages/turf-nearest-point/bench.ts +++ b/packages/turf-nearest-point/bench.ts @@ -1,7 +1,10 @@ import path from "path"; +import { fileURLToPath } from "url"; import Benchmark from "benchmark"; import { loadJsonFileSync } from "load-json-file"; -import { nearestPoint } from "./index"; +import { nearestPoint } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const pts = loadJsonFileSync(path.join(__dirname, "test", "in", "points.json")); diff --git a/packages/turf-nearest-point/package.json b/packages/turf-nearest-point/package.json index 0829f8bbb2..7f48b4e238 100644 --- a/packages/turf-nearest-point/package.json +++ b/packages/turf-nearest-point/package.json @@ -24,19 +24,19 @@ "nearest", "point" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -51,17 +51,19 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", + "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", - "typescript": "^5.2.2" + "typescript": "^5.2.2", + "write-json-file": "^5.0.0" }, "dependencies": { "@turf/clone": "workspace:^", diff --git a/packages/turf-nearest-point/test.ts b/packages/turf-nearest-point/test.ts index 821e3c490f..f3dd3fbc42 100644 --- a/packages/turf-nearest-point/test.ts +++ b/packages/turf-nearest-point/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureCollection, point } from "@turf/helpers"; -import { nearestPoint } from "./index"; +import { nearestPoint } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-nearest-point/types.ts b/packages/turf-nearest-point/types.ts index 4ee643bcde..4aeb5ac610 100644 --- a/packages/turf-nearest-point/types.ts +++ b/packages/turf-nearest-point/types.ts @@ -1,5 +1,5 @@ import { point, featureCollection } from "@turf/helpers"; -import { nearestPoint } from "./index"; +import { nearestPoint } from "./index.js"; const targetPoint = point([28.965797, 41.010086], { "marker-color": "#0F0" }); const points = featureCollection([ diff --git a/packages/turf-planepoint/bench.ts b/packages/turf-planepoint/bench.ts index 4c47aba84e..345ad33e67 100644 --- a/packages/turf-planepoint/bench.ts +++ b/packages/turf-planepoint/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { polygon } from "@turf/helpers"; -import { planepoint } from "./index"; +import { planepoint } from "./index.js"; const point = [1, 1]; const triangle = polygon( diff --git a/packages/turf-planepoint/package.json b/packages/turf-planepoint/package.json index 7d42d498de..b54ef65627 100644 --- a/packages/turf-planepoint/package.json +++ b/packages/turf-planepoint/package.json @@ -23,27 +23,26 @@ "point", "interpolation" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -51,7 +50,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "benchmark": "^2.1.4", diff --git a/packages/turf-planepoint/test.ts b/packages/turf-planepoint/test.ts index daeb2fdcb1..e6c145a505 100644 --- a/packages/turf-planepoint/test.ts +++ b/packages/turf-planepoint/test.ts @@ -3,7 +3,7 @@ import test from "tape"; import { polygon } from "@turf/helpers"; -import { planepoint } from "./index"; +import { planepoint } from "./index.js"; test("turf-planepoint", (t) => { const point = [1, 1]; diff --git a/packages/turf-planepoint/types.ts b/packages/turf-planepoint/types.ts index 8779af3fd7..edbbb1739c 100644 --- a/packages/turf-planepoint/types.ts +++ b/packages/turf-planepoint/types.ts @@ -1,5 +1,5 @@ import { point, polygon } from "@turf/helpers"; -import { planepoint } from "./index"; +import { planepoint } from "./index.js"; const pt = point([1, 1]); const triangle = polygon([ diff --git a/packages/turf-point-grid/bench.ts b/packages/turf-point-grid/bench.ts index bd6f0eaa6a..2092273660 100644 --- a/packages/turf-point-grid/bench.ts +++ b/packages/turf-point-grid/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { polygon } from "@turf/helpers"; -import { pointGrid as grid } from "./index"; +import { pointGrid as grid } from "./index.js"; var bbox = [-95, 30, -85, 40]; var mask = polygon([ diff --git a/packages/turf-point-grid/package.json b/packages/turf-point-grid/package.json index 003190f21c..8c7033ba78 100644 --- a/packages/turf-point-grid/package.json +++ b/packages/turf-point-grid/package.json @@ -26,19 +26,19 @@ "points", "geojson" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-point-grid/test.ts b/packages/turf-point-grid/test.ts index 3e54ac7fe7..7721d3aa5e 100644 --- a/packages/turf-point-grid/test.ts +++ b/packages/turf-point-grid/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; import { truncate } from "@turf/truncate"; -import { pointGrid } from "./index"; +import { pointGrid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-point-grid/types.ts b/packages/turf-point-grid/types.ts index 2504e9bc8e..8eb9a3eb13 100644 --- a/packages/turf-point-grid/types.ts +++ b/packages/turf-point-grid/types.ts @@ -1,6 +1,6 @@ import { BBox } from "geojson"; import { polygon } from "@turf/helpers"; -import { pointGrid } from "./index"; +import { pointGrid } from "./index.js"; const cellSide = 50; const bbox: BBox = [-95, 30, -85, 40]; diff --git a/packages/turf-point-on-feature/bench.ts b/packages/turf-point-on-feature/bench.ts index c3255b4cbd..d7c7c6e44c 100644 --- a/packages/turf-point-on-feature/bench.ts +++ b/packages/turf-point-on-feature/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { pointOnFeature } from "./index"; +import { pointOnFeature } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** * Benchmark Results diff --git a/packages/turf-point-on-feature/package.json b/packages/turf-point-on-feature/package.json index 219c19c880..41894bc26d 100644 --- a/packages/turf-point-on-feature/package.json +++ b/packages/turf-point-on-feature/package.json @@ -24,19 +24,19 @@ "surface", "polygon" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -62,7 +62,8 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", - "typescript": "^5.2.2" + "typescript": "^5.2.2", + "write-json-file": "^5.0.0" }, "dependencies": { "@turf/boolean-point-in-polygon": "workspace:^", diff --git a/packages/turf-point-on-feature/test.ts b/packages/turf-point-on-feature/test.ts index f54ab546de..b801085a80 100644 --- a/packages/turf-point-on-feature/test.ts +++ b/packages/turf-point-on-feature/test.ts @@ -1,12 +1,15 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureEach } from "@turf/meta"; import { featureCollection } from "@turf/helpers"; -import { pointOnFeature } from "./index"; +import { pointOnFeature } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-point-on-feature", (t) => { glob diff --git a/packages/turf-point-to-line-distance/bench.ts b/packages/turf-point-to-line-distance/bench.ts index cc16fa1feb..a1f9b2e15c 100644 --- a/packages/turf-point-to-line-distance/bench.ts +++ b/packages/turf-point-to-line-distance/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { pointToLineDistance } from "./index"; +import { pointToLineDistance } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-point-to-line-distance/package.json b/packages/turf-point-to-line-distance/package.json index 3dfd1dfada..4f2bf721f4 100644 --- a/packages/turf-point-to-line-distance/package.json +++ b/packages/turf-point-to-line-distance/package.json @@ -24,19 +24,19 @@ "point-to-line-distance", "distance" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/circle": "workspace:^", diff --git a/packages/turf-point-to-line-distance/test.ts b/packages/turf-point-to-line-distance/test.ts index 7ac0baa61e..ffbc640cc2 100644 --- a/packages/turf-point-to-line-distance/test.ts +++ b/packages/turf-point-to-line-distance/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { circle } from "@turf/circle"; import { point, lineString, round } from "@turf/helpers"; -import { pointToLineDistance } from "./index"; +import { pointToLineDistance } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-point-to-line-distance/types.ts b/packages/turf-point-to-line-distance/types.ts index 5d34749875..b9c198b17b 100644 --- a/packages/turf-point-to-line-distance/types.ts +++ b/packages/turf-point-to-line-distance/types.ts @@ -1,5 +1,5 @@ import { point, lineString } from "@turf/helpers"; -import { pointToLineDistance } from "./index"; +import { pointToLineDistance } from "./index.js"; const pt = point([0, 0]); const line = lineString([ diff --git a/packages/turf-points-within-polygon/bench.ts b/packages/turf-points-within-polygon/bench.ts index 8b20e65b0b..03eab4e13f 100644 --- a/packages/turf-points-within-polygon/bench.ts +++ b/packages/turf-points-within-polygon/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { featureCollection, point, polygon } from "@turf/helpers"; -import { pointsWithinPolygon } from "./index"; +import { pointsWithinPolygon } from "./index.js"; var poly1 = polygon([ [ diff --git a/packages/turf-points-within-polygon/package.json b/packages/turf-points-within-polygon/package.json index 7c578bf828..659f2ece51 100644 --- a/packages/turf-points-within-polygon/package.json +++ b/packages/turf-points-within-polygon/package.json @@ -23,19 +23,19 @@ "polygon", "featurecollection" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -50,7 +50,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-points-within-polygon/test.ts b/packages/turf-points-within-polygon/test.ts index 95b48d6a2a..d59ba8ffb7 100644 --- a/packages/turf-points-within-polygon/test.ts +++ b/packages/turf-points-within-polygon/test.ts @@ -2,7 +2,7 @@ import test from "tape"; import { multiPoint, point, points } from "@turf/helpers"; import { polygon } from "@turf/helpers"; import { featureCollection } from "@turf/helpers"; -import { pointsWithinPolygon } from "./index"; +import { pointsWithinPolygon } from "./index.js"; test("turf-points-within-polygon -- point", (t) => { t.plan(4); diff --git a/packages/turf-points-within-polygon/types.ts b/packages/turf-points-within-polygon/types.ts index 1d3698cc3d..8597843653 100644 --- a/packages/turf-points-within-polygon/types.ts +++ b/packages/turf-points-within-polygon/types.ts @@ -1,5 +1,5 @@ import { Point, MultiPoint } from "geojson"; -import { pointsWithinPolygon } from "./"; +import { pointsWithinPolygon } from "./index.js"; import { points, polygon, multiPoint, featureCollection } from "@turf/helpers"; const pts = points([ diff --git a/packages/turf-polygon-smooth/bench.ts b/packages/turf-polygon-smooth/bench.ts index d52ad499a7..5e3ec6b7c4 100644 --- a/packages/turf-polygon-smooth/bench.ts +++ b/packages/turf-polygon-smooth/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { polygonSmooth } from "./index"; +import { polygonSmooth } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-polygon-smooth/package.json b/packages/turf-polygon-smooth/package.json index 96d756b4fb..2e4e0228ca 100644 --- a/packages/turf-polygon-smooth/package.json +++ b/packages/turf-polygon-smooth/package.json @@ -24,19 +24,19 @@ "geojson", "polygon" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-polygon-smooth/test.ts b/packages/turf-polygon-smooth/test.ts index 3a68a61fb7..a131d42448 100644 --- a/packages/turf-polygon-smooth/test.ts +++ b/packages/turf-polygon-smooth/test.ts @@ -2,9 +2,12 @@ import { polygon } from "@turf/helpers"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { writeJsonFileSync } from "write-json-file"; -import { polygonSmooth } from "./index"; +import { polygonSmooth } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-polygon-smooth", (t) => { glob diff --git a/packages/turf-polygon-smooth/types.ts b/packages/turf-polygon-smooth/types.ts index 62c3fb8b79..1519280ad0 100644 --- a/packages/turf-polygon-smooth/types.ts +++ b/packages/turf-polygon-smooth/types.ts @@ -1,5 +1,5 @@ import { polygon } from "@turf/helpers"; -import { polygonSmooth } from "./index"; +import { polygonSmooth } from "./index.js"; const poly = polygon([ [ diff --git a/packages/turf-polygon-tangents/bench.ts b/packages/turf-polygon-tangents/bench.ts index 3485a9ca38..31d0a2313a 100644 --- a/packages/turf-polygon-tangents/bench.ts +++ b/packages/turf-polygon-tangents/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { polygonTangents as tangents } from "./index"; +import { polygonTangents as tangents } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-polygon-tangents/package.json b/packages/turf-polygon-tangents/package.json index 16c0ebe9ca..11b4934948 100644 --- a/packages/turf-polygon-tangents/package.json +++ b/packages/turf-polygon-tangents/package.json @@ -27,19 +27,19 @@ "tangent", "polygon" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-polygon-tangents/test.ts b/packages/turf-polygon-tangents/test.ts index d350ce9611..cae2f35ab5 100644 --- a/packages/turf-polygon-tangents/test.ts +++ b/packages/turf-polygon-tangents/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { polygon, point } from "@turf/helpers"; -import { polygonTangents } from "./index"; +import { polygonTangents } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-polygon-tangents/types.ts b/packages/turf-polygon-tangents/types.ts index 625637708b..dd02ba927d 100644 --- a/packages/turf-polygon-tangents/types.ts +++ b/packages/turf-polygon-tangents/types.ts @@ -1,5 +1,5 @@ import { polygon, point } from "@turf/helpers"; -import { polygonTangents as tangents } from "./index"; +import { polygonTangents as tangents } from "./index.js"; const poly = polygon([ [ diff --git a/packages/turf-polygon-to-line/bench.ts b/packages/turf-polygon-to-line/bench.ts index 2d18839dba..47a8b900b6 100644 --- a/packages/turf-polygon-to-line/bench.ts +++ b/packages/turf-polygon-to-line/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { polygonToLine } from "./index"; +import { polygonToLine } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-polygon-to-line/package.json b/packages/turf-polygon-to-line/package.json index c114f25a7e..1f2716b266 100644 --- a/packages/turf-polygon-to-line/package.json +++ b/packages/turf-polygon-to-line/package.json @@ -23,19 +23,19 @@ "linestring", "polygon" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-polygon-to-line/test.ts b/packages/turf-polygon-to-line/test.ts index 360ea326f8..e7c573089a 100644 --- a/packages/turf-polygon-to-line/test.ts +++ b/packages/turf-polygon-to-line/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point } from "@turf/helpers"; import { polygon } from "@turf/helpers"; -import { polygonToLine } from "./index"; +import { polygonToLine } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-polygonize/bench.ts b/packages/turf-polygonize/bench.ts index 059b4e0389..5af62c7338 100644 --- a/packages/turf-polygonize/bench.ts +++ b/packages/turf-polygonize/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { polygonize } from "./index"; +import { polygonize } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-polygonize/index.ts b/packages/turf-polygonize/index.ts index 958368a543..30f4e75295 100644 --- a/packages/turf-polygonize/index.ts +++ b/packages/turf-polygonize/index.ts @@ -6,8 +6,8 @@ import { Polygon, } from "geojson"; import { featureCollection } from "@turf/helpers"; -import { Graph } from "./lib/Graph"; -import { EdgeRing } from "./lib/EdgeRing"; +import { Graph } from "./lib/Graph.js"; +import { EdgeRing } from "./lib/EdgeRing.js"; /** * Polygonizes {@link LineString|(Multi)LineString(s)} into {@link Polygons}. diff --git a/packages/turf-polygonize/lib/Edge.ts b/packages/turf-polygonize/lib/Edge.ts index 4e78b5e462..76239e3530 100644 --- a/packages/turf-polygonize/lib/Edge.ts +++ b/packages/turf-polygonize/lib/Edge.ts @@ -1,7 +1,7 @@ import { lineString } from "@turf/helpers"; -import { orientationIndex } from "./util"; -import { Node } from "./Node"; -import { EdgeRing } from "./EdgeRing"; +import { orientationIndex } from "./util.js"; +import { Node } from "./Node.js"; +import { EdgeRing } from "./EdgeRing.js"; /** * This class is inspired by GEOS's geos::operation::polygonize::PolygonizeDirectedEdge diff --git a/packages/turf-polygonize/lib/EdgeRing.ts b/packages/turf-polygonize/lib/EdgeRing.ts index 98e1e66ac4..c087cb3887 100644 --- a/packages/turf-polygonize/lib/EdgeRing.ts +++ b/packages/turf-polygonize/lib/EdgeRing.ts @@ -4,11 +4,11 @@ import { envelopeIsEqual, envelopeContains, coordinatesEqual, -} from "./util"; +} from "./util.js"; import { multiPoint, polygon, point } from "@turf/helpers"; import { envelope } from "@turf/envelope"; import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon"; -import { Edge } from "./Edge"; +import { Edge } from "./Edge.js"; /** * Ring of edges which form a polygon. diff --git a/packages/turf-polygonize/lib/Graph.ts b/packages/turf-polygonize/lib/Graph.ts index 6dc7e57f45..bd9f9f3fbc 100644 --- a/packages/turf-polygonize/lib/Graph.ts +++ b/packages/turf-polygonize/lib/Graph.ts @@ -1,6 +1,6 @@ -import { Node } from "./Node"; -import { Edge } from "./Edge"; -import { EdgeRing } from "./EdgeRing"; +import { Node } from "./Node.js"; +import { Edge } from "./Edge.js"; +import { EdgeRing } from "./EdgeRing.js"; import { flattenEach, coordReduce } from "@turf/meta"; import { featureOf } from "@turf/invariant"; import { diff --git a/packages/turf-polygonize/lib/Node.ts b/packages/turf-polygonize/lib/Node.ts index 8dbe18c9ee..99dae44201 100644 --- a/packages/turf-polygonize/lib/Node.ts +++ b/packages/turf-polygonize/lib/Node.ts @@ -1,5 +1,5 @@ -import { orientationIndex } from "./util"; -import { Edge } from "./Edge"; +import { orientationIndex } from "./util.js"; +import { Edge } from "./Edge.js"; /** * Node diff --git a/packages/turf-polygonize/package.json b/packages/turf-polygonize/package.json index 899e755f6a..617281b080 100644 --- a/packages/turf-polygonize/package.json +++ b/packages/turf-polygonize/package.json @@ -26,19 +26,19 @@ "gis", "polygonize" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-polygonize/test.ts b/packages/turf-polygonize/test.ts index 14ee097413..c45470a78b 100644 --- a/packages/turf-polygonize/test.ts +++ b/packages/turf-polygonize/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; import { featureCollection, lineString } from "@turf/helpers"; -import { polygonize } from "./index"; +import { polygonize } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-polygonize/types.ts b/packages/turf-polygonize/types.ts index d23a266cf0..80bc1e456c 100644 --- a/packages/turf-polygonize/types.ts +++ b/packages/turf-polygonize/types.ts @@ -1,5 +1,5 @@ import { lineString } from "@turf/helpers"; -import { polygonize } from "./index"; +import { polygonize } from "./index.js"; const line = lineString([ [10, 10], diff --git a/packages/turf-projection/bench.ts b/packages/turf-projection/bench.ts index 655355a951..2ef788e4f4 100644 --- a/packages/turf-projection/bench.ts +++ b/packages/turf-projection/bench.ts @@ -1,8 +1,11 @@ import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { toMercator, toWgs84 } from "./index"; +import { toMercator, toWgs84 } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const suite = new Benchmark.Suite("turf-projection"); diff --git a/packages/turf-projection/package.json b/packages/turf-projection/package.json index afa7661a8a..983f6c11ff 100644 --- a/packages/turf-projection/package.json +++ b/packages/turf-projection/package.json @@ -34,19 +34,19 @@ "EPSG:900913", "EPSG:102113" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -61,7 +61,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-projection/test.ts b/packages/turf-projection/test.ts index 5ab69bf82c..ee4ebf34ce 100644 --- a/packages/turf-projection/test.ts +++ b/packages/turf-projection/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import proj4 from "proj4"; import { writeJsonFileSync } from "write-json-file"; @@ -8,7 +9,9 @@ import { clone } from "@turf/clone"; import { point } from "@turf/helpers"; import { truncate } from "@turf/truncate"; import { coordEach } from "@turf/meta"; -import { toMercator, toWgs84 } from "./index"; +import { toMercator, toWgs84 } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { mercator: path.join(__dirname, "test", "mercator") + path.sep, diff --git a/packages/turf-projection/types.ts b/packages/turf-projection/types.ts index 56eabd9960..55e7ead1f2 100644 --- a/packages/turf-projection/types.ts +++ b/packages/turf-projection/types.ts @@ -1,5 +1,5 @@ -import * as projection from "./index"; -import { toMercator, toWgs84 } from "./index"; +import * as projection from "./index.js"; +import { toMercator, toWgs84 } from "./index.js"; import { point } from "@turf/helpers"; // Types test diff --git a/packages/turf-quadrat-analysis/bench.ts b/packages/turf-quadrat-analysis/bench.ts index 867d0ed7b4..2e420f94b5 100644 --- a/packages/turf-quadrat-analysis/bench.ts +++ b/packages/turf-quadrat-analysis/bench.ts @@ -1,7 +1,7 @@ import Benchmark from "benchmark"; import { randomPoint } from "@turf/random"; import { nearestNeighborAnalysis } from "@turf/nearest-neighbor-analysis"; -import { quadratAnalysis } from "./index"; +import { quadratAnalysis } from "./index.js"; /** * Benchmark Results diff --git a/packages/turf-quadrat-analysis/package.json b/packages/turf-quadrat-analysis/package.json index f20c7eb376..3ce3a7d9c1 100644 --- a/packages/turf-quadrat-analysis/package.json +++ b/packages/turf-quadrat-analysis/package.json @@ -23,19 +23,19 @@ "turf", "quadrat-analysis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-quadrat-analysis/test.ts b/packages/turf-quadrat-analysis/test.ts index b71356afe2..39855242a9 100644 --- a/packages/turf-quadrat-analysis/test.ts +++ b/packages/turf-quadrat-analysis/test.ts @@ -1,5 +1,6 @@ import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { bbox } from "@turf/bbox"; @@ -8,9 +9,11 @@ import { squareGrid } from "@turf/square-grid"; import { bboxPolygon } from "@turf/bbox-polygon"; import { randomPoint } from "@turf/random"; import { featureCollection } from "@turf/helpers"; -import { quadratAnalysis } from "./index"; +import { quadratAnalysis } from "./index.js"; import fs from "fs"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + test("turf-quadrat-analysis geojson file", (t) => { const futianBboxPath = path.join(__dirname, "test", "in", "futian_bbox.json"); const futianPointPath = path.join( diff --git a/packages/turf-random/bench.ts b/packages/turf-random/bench.ts index a82fae0842..f5ddaa89db 100644 --- a/packages/turf-random/bench.ts +++ b/packages/turf-random/bench.ts @@ -1,7 +1,7 @@ // I don't think this bench test does anything? There is no entry point into // the module called random() that takes a string? -import { random } from "./index"; +import { random } from "./index.js"; import Benchmark from "benchmark"; var suite = new Benchmark.Suite("turf-random"); diff --git a/packages/turf-random/package.json b/packages/turf-random/package.json index 7057e6ba5e..7d078e8268 100644 --- a/packages/turf-random/package.json +++ b/packages/turf-random/package.json @@ -20,19 +20,19 @@ "turf", "gis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-random/test.ts b/packages/turf-random/test.ts index a6f619581e..d42294cf9a 100644 --- a/packages/turf-random/test.ts +++ b/packages/turf-random/test.ts @@ -4,7 +4,7 @@ import { randomPolygon, randomLineString, randomPosition, -} from "./index"; +} from "./index.js"; test("random(points)", (t) => { var points = randomPoint(); diff --git a/packages/turf-rectangle-grid/bench.ts b/packages/turf-rectangle-grid/bench.ts index 8562eae704..07b3e5937e 100644 --- a/packages/turf-rectangle-grid/bench.ts +++ b/packages/turf-rectangle-grid/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { rectangleGrid } from "./index"; +import { rectangleGrid } from "./index.js"; var bbox = [-95, 30, -85, 40]; diff --git a/packages/turf-rectangle-grid/package.json b/packages/turf-rectangle-grid/package.json index f5ee2ae136..d4b05994de 100644 --- a/packages/turf-rectangle-grid/package.json +++ b/packages/turf-rectangle-grid/package.json @@ -26,19 +26,19 @@ "regular", "cartesian" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-rectangle-grid/test.ts b/packages/turf-rectangle-grid/test.ts index 48a2ec0e4d..e31cac3b58 100644 --- a/packages/turf-rectangle-grid/test.ts +++ b/packages/turf-rectangle-grid/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; import { truncate } from "@turf/truncate"; -import { rectangleGrid } from "./index"; +import { rectangleGrid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-rewind/bench.ts b/packages/turf-rewind/bench.ts index 5e6107bc38..84b0d4c0ce 100644 --- a/packages/turf-rewind/bench.ts +++ b/packages/turf-rewind/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { rewind } from "./index"; +import { rewind } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-rewind/package.json b/packages/turf-rewind/package.json index 88e885a3f2..ed601d4bca 100644 --- a/packages/turf-rewind/package.json +++ b/packages/turf-rewind/package.json @@ -28,19 +28,19 @@ "polygon", "rewind" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-rewind/test.ts b/packages/turf-rewind/test.ts index 267644e7f3..3557e38653 100644 --- a/packages/turf-rewind/test.ts +++ b/packages/turf-rewind/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { @@ -9,7 +10,9 @@ import { featureCollection, geometryCollection, } from "@turf/helpers"; -import { rewind } from "./index"; +import { rewind } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-rewind/types.ts b/packages/turf-rewind/types.ts index 73d42efcbf..a87727cd83 100644 --- a/packages/turf-rewind/types.ts +++ b/packages/turf-rewind/types.ts @@ -4,7 +4,7 @@ import { multiLineString, multiPolygon, } from "@turf/helpers"; -import { rewind } from "./index"; +import { rewind } from "./index.js"; const coords = [ [121, -29], diff --git a/packages/turf-rhumb-bearing/bench.ts b/packages/turf-rhumb-bearing/bench.ts index a0fba6ea7e..74e015b497 100644 --- a/packages/turf-rhumb-bearing/bench.ts +++ b/packages/turf-rhumb-bearing/bench.ts @@ -1,6 +1,6 @@ import { point } from "@turf/helpers"; import Benchmark from "benchmark"; -import { rhumbBearing } from "./index"; +import { rhumbBearing } from "./index.js"; var start = point([-75.4, 39.4]); var end = point([-75.534, 39.123]); diff --git a/packages/turf-rhumb-bearing/package.json b/packages/turf-rhumb-bearing/package.json index 2e407b9631..41c00a1a93 100644 --- a/packages/turf-rhumb-bearing/package.json +++ b/packages/turf-rhumb-bearing/package.json @@ -28,19 +28,19 @@ "rhumb", "rhumb line" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-rhumb-bearing/test.ts b/packages/turf-rhumb-bearing/test.ts index 3648110d81..377a0c9a41 100644 --- a/packages/turf-rhumb-bearing/test.ts +++ b/packages/turf-rhumb-bearing/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point } from "@turf/helpers"; -import { rhumbBearing } from "./index"; +import { rhumbBearing } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-rhumb-destination/bench.ts b/packages/turf-rhumb-destination/bench.ts index 6940e63273..d6f8b27b87 100644 --- a/packages/turf-rhumb-destination/bench.ts +++ b/packages/turf-rhumb-destination/bench.ts @@ -1,6 +1,6 @@ import { point } from "@turf/helpers"; import Benchmark from "benchmark"; -import { rhumbDestination as destination } from "./index"; +import { rhumbDestination as destination } from "./index.js"; const pt1 = point([-75.0, 39.0]); const distance = 100; diff --git a/packages/turf-rhumb-destination/package.json b/packages/turf-rhumb-destination/package.json index b133bf94ad..0748f9a5ea 100644 --- a/packages/turf-rhumb-destination/package.json +++ b/packages/turf-rhumb-destination/package.json @@ -32,19 +32,19 @@ "miles", "km" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-rhumb-destination/test.ts b/packages/turf-rhumb-destination/test.ts index 15872c50ba..b008484e0c 100644 --- a/packages/turf-rhumb-destination/test.ts +++ b/packages/turf-rhumb-destination/test.ts @@ -1,12 +1,15 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { writeJsonFileSync } from "write-json-file"; import { loadJsonFileSync } from "load-json-file"; import { truncate } from "@turf/truncate"; import { getCoords } from "@turf/invariant"; import { featureCollection, lineString, point } from "@turf/helpers"; -import { rhumbDestination } from "./index"; +import { rhumbDestination } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-rhumb-distance/bench.ts b/packages/turf-rhumb-distance/bench.ts index e1116bc45d..0bb5c3eac7 100644 --- a/packages/turf-rhumb-distance/bench.ts +++ b/packages/turf-rhumb-distance/bench.ts @@ -1,6 +1,6 @@ import { point } from "@turf/helpers"; import Benchmark from "benchmark"; -import { rhumbDistance as distance } from "./index"; +import { rhumbDistance as distance } from "./index.js"; const pt1 = point([-75.4, 39.4]); const pt2 = point([-75.534, 39.123]); diff --git a/packages/turf-rhumb-distance/package.json b/packages/turf-rhumb-distance/package.json index 5e2cd9a506..102cee10a4 100644 --- a/packages/turf-rhumb-distance/package.json +++ b/packages/turf-rhumb-distance/package.json @@ -30,19 +30,19 @@ "miles", "km" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-rhumb-distance/test.ts b/packages/turf-rhumb-distance/test.ts index 2c7f5dbe77..2bdc43b67f 100644 --- a/packages/turf-rhumb-distance/test.ts +++ b/packages/turf-rhumb-distance/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { distance } from "@turf/distance"; import { point, round } from "@turf/helpers"; -import { rhumbDistance } from "./index"; +import { rhumbDistance } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-sample/bench.ts b/packages/turf-sample/bench.ts index ee06de1fde..69e528d326 100644 --- a/packages/turf-sample/bench.ts +++ b/packages/turf-sample/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { point, featureCollection } from "@turf/helpers"; -import { sample } from "./index"; +import { sample } from "./index.js"; var points = featureCollection([ point(1, 2, { team: "Red Sox" }), diff --git a/packages/turf-sample/package.json b/packages/turf-sample/package.json index 8c605db6a8..e16cc44b6b 100644 --- a/packages/turf-sample/package.json +++ b/packages/turf-sample/package.json @@ -22,19 +22,19 @@ "sample", "turf" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-sample/test.ts b/packages/turf-sample/test.ts index 0cab3584a6..1d99e92f3e 100644 --- a/packages/turf-sample/test.ts +++ b/packages/turf-sample/test.ts @@ -1,7 +1,7 @@ import test from "tape"; import { point } from "@turf/helpers"; import { featureCollection } from "@turf/helpers"; -import { sample } from "./index"; +import { sample } from "./index.js"; test("remove", function (t) { var points = featureCollection([ diff --git a/packages/turf-sector/bench.ts b/packages/turf-sector/bench.ts index b2d61ae89e..672238f39d 100644 --- a/packages/turf-sector/bench.ts +++ b/packages/turf-sector/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { sector } from "./index"; +import { sector } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-sector/package.json b/packages/turf-sector/package.json index 48dd522f17..ebd61a41a1 100644 --- a/packages/turf-sector/package.json +++ b/packages/turf-sector/package.json @@ -20,19 +20,19 @@ "turf", "gif" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -47,7 +47,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-sector/test.ts b/packages/turf-sector/test.ts index af22c5c50a..c9f27aff5e 100644 --- a/packages/turf-sector/test.ts +++ b/packages/turf-sector/test.ts @@ -1,11 +1,14 @@ import test from "tape"; import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureCollection } from "@turf/helpers"; -import { sector } from "./index"; +import { sector } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-sector/types.ts b/packages/turf-sector/types.ts index b6df769d7f..acc42b6b33 100644 --- a/packages/turf-sector/types.ts +++ b/packages/turf-sector/types.ts @@ -1,5 +1,5 @@ import { point } from "@turf/helpers"; -import { sector } from "./index"; +import { sector } from "./index.js"; const center = point([-75.343, 39.984]); const units = "kilometers"; diff --git a/packages/turf-shortest-path/bench.ts b/packages/turf-shortest-path/bench.ts index 841d2d8744..81cf185895 100644 --- a/packages/turf-shortest-path/bench.ts +++ b/packages/turf-shortest-path/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { shortestPath } from "./index"; +import { shortestPath } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-shortest-path/index.ts b/packages/turf-shortest-path/index.ts index 72bac3bd95..33908b2c81 100644 --- a/packages/turf-shortest-path/index.ts +++ b/packages/turf-shortest-path/index.ts @@ -23,7 +23,7 @@ import { featureCollection, feature, } from "@turf/helpers"; -import { Graph, GridNode, astar } from "./lib/javascript-astar"; +import { Graph, GridNode, astar } from "./lib/javascript-astar.js"; /** * Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with diff --git a/packages/turf-shortest-path/package.json b/packages/turf-shortest-path/package.json index 3cd7600a20..62b1c9bc66 100644 --- a/packages/turf-shortest-path/package.json +++ b/packages/turf-shortest-path/package.json @@ -25,19 +25,19 @@ "shortest-path", "path" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -52,7 +52,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-shortest-path/test.ts b/packages/turf-shortest-path/test.ts index d40ceb175d..483ce56891 100644 --- a/packages/turf-shortest-path/test.ts +++ b/packages/turf-shortest-path/test.ts @@ -1,13 +1,16 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { featureCollection, point } from "@turf/helpers"; import { getCoord } from "@turf/invariant"; import { featureEach } from "@turf/meta"; -import { shortestPath } from "./index"; +import { shortestPath } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-shortest-path/types.ts b/packages/turf-shortest-path/types.ts index c21e6ca859..845fa80144 100644 --- a/packages/turf-shortest-path/types.ts +++ b/packages/turf-shortest-path/types.ts @@ -1,5 +1,5 @@ import { point, featureCollection, polygon } from "@turf/helpers"; -import { shortestPath } from "./index"; +import { shortestPath } from "./index.js"; const start = point([-5, -6]); const end = point([9, -6]); diff --git a/packages/turf-simplify/bench.ts b/packages/turf-simplify/bench.ts index d03935d96c..e914705cba 100644 --- a/packages/turf-simplify/bench.ts +++ b/packages/turf-simplify/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { simplify } from "./index"; +import { simplify } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-simplify/index.ts b/packages/turf-simplify/index.ts index dce57dc979..ec2d26cd05 100644 --- a/packages/turf-simplify/index.ts +++ b/packages/turf-simplify/index.ts @@ -3,7 +3,7 @@ import { cleanCoords } from "@turf/clean-coords"; import { clone } from "@turf/clone"; import { geomEach } from "@turf/meta"; import { AllGeoJSON, isObject } from "@turf/helpers"; -import { simplify as simplifyJS } from "./lib/simplify"; +import { simplify as simplifyJS } from "./lib/simplify.js"; /** * Takes a {@link GeoJSON} object and returns a simplified version. Internally uses the 2d version of diff --git a/packages/turf-simplify/package.json b/packages/turf-simplify/package.json index 9f2746bc23..2c91178a5c 100644 --- a/packages/turf-simplify/package.json +++ b/packages/turf-simplify/package.json @@ -28,19 +28,19 @@ "algorithm", "peucker" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-simplify/test.ts b/packages/turf-simplify/test.ts index 762c89cd7f..e033c573ae 100644 --- a/packages/turf-simplify/test.ts +++ b/packages/turf-simplify/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; import { polygon, multiPolygon } from "@turf/helpers"; -import { simplify } from "./index"; +import { simplify } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-simplify/types.ts b/packages/turf-simplify/types.ts index efb8f29972..c5d5dda23a 100644 --- a/packages/turf-simplify/types.ts +++ b/packages/turf-simplify/types.ts @@ -1,6 +1,6 @@ import { Feature, Polygon } from "geojson"; import { polygon } from "@turf/helpers"; -import { simplify } from "./index"; +import { simplify } from "./index.js"; const poly = polygon([ [ diff --git a/packages/turf-square-grid/bench.ts b/packages/turf-square-grid/bench.ts index 306fadd970..83a669f1e4 100644 --- a/packages/turf-square-grid/bench.ts +++ b/packages/turf-square-grid/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { squareGrid } from "./index"; +import { squareGrid } from "./index.js"; var bbox = [-95, 30, -85, 40]; diff --git a/packages/turf-square-grid/package.json b/packages/turf-square-grid/package.json index c8bb97ae4d..7e35c40bd5 100644 --- a/packages/turf-square-grid/package.json +++ b/packages/turf-square-grid/package.json @@ -23,19 +23,19 @@ "cartesian", "grid" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-square-grid/test.ts b/packages/turf-square-grid/test.ts index e2d64dd08b..0c18f8d94b 100644 --- a/packages/turf-square-grid/test.ts +++ b/packages/turf-square-grid/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; import { truncate } from "@turf/truncate"; -import { squareGrid } from "./index"; +import { squareGrid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-square/bench.ts b/packages/turf-square/bench.ts index e09d853844..21bca3ef4f 100644 --- a/packages/turf-square/bench.ts +++ b/packages/turf-square/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { square } from "./index"; +import { square } from "./index.js"; var bbox = [0, 0, 5, 10]; diff --git a/packages/turf-square/package.json b/packages/turf-square/package.json index 88d033bc30..7d75879518 100644 --- a/packages/turf-square/package.json +++ b/packages/turf-square/package.json @@ -22,27 +22,26 @@ "geojson", "extent" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", diff --git a/packages/turf-square/test.ts b/packages/turf-square/test.ts index 0183373566..d1fcdd9330 100644 --- a/packages/turf-square/test.ts +++ b/packages/turf-square/test.ts @@ -1,5 +1,5 @@ import test from "tape"; -import { square } from "./index"; +import { square } from "./index.js"; test("square", function (t) { var bbox1 = [0, 0, 5, 10]; diff --git a/packages/turf-standard-deviational-ellipse/bench.ts b/packages/turf-standard-deviational-ellipse/bench.ts index 37c74c4665..e46a44c467 100644 --- a/packages/turf-standard-deviational-ellipse/bench.ts +++ b/packages/turf-standard-deviational-ellipse/bench.ts @@ -1,5 +1,5 @@ import { randomPoint } from "@turf/random"; -import { standardDeviationalEllipse } from "./index"; +import { standardDeviationalEllipse } from "./index.js"; import Benchmark from "benchmark"; /** diff --git a/packages/turf-standard-deviational-ellipse/package.json b/packages/turf-standard-deviational-ellipse/package.json index ae12ec08a3..5606618e12 100644 --- a/packages/turf-standard-deviational-ellipse/package.json +++ b/packages/turf-standard-deviational-ellipse/package.json @@ -25,27 +25,26 @@ "geostatistics", "directional distribution" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -53,11 +52,13 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/random": "workspace:^", "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-standard-deviational-ellipse/test.ts b/packages/turf-standard-deviational-ellipse/test.ts index 146aaa24f8..84b5c6f1c6 100644 --- a/packages/turf-standard-deviational-ellipse/test.ts +++ b/packages/turf-standard-deviational-ellipse/test.ts @@ -1,10 +1,13 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureCollection } from "@turf/helpers"; -import { standardDeviationalEllipse } from "./index"; +import { standardDeviationalEllipse } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-standard-deviational-ellipse", (t) => { glob diff --git a/packages/turf-standard-deviational-ellipse/types.ts b/packages/turf-standard-deviational-ellipse/types.ts index df6bf5eccd..8f06c60a36 100644 --- a/packages/turf-standard-deviational-ellipse/types.ts +++ b/packages/turf-standard-deviational-ellipse/types.ts @@ -1,5 +1,5 @@ import { points } from "@turf/helpers"; -import { standardDeviationalEllipse } from "./index"; +import { standardDeviationalEllipse } from "./index.js"; const pts = points([ [10, 10], diff --git a/packages/turf-tag/bench.ts b/packages/turf-tag/bench.ts index 4b6aa9ed4c..b77eb1ecad 100644 --- a/packages/turf-tag/bench.ts +++ b/packages/turf-tag/bench.ts @@ -1,6 +1,6 @@ import fs from "fs"; import Benchmark from "benchmark"; -import { tag } from "./index"; +import { tag } from "./index.js"; var points = JSON.parse(fs.readFileSync("./test/tagPoints.geojson")); var polygons = JSON.parse(fs.readFileSync("./test/tagPolygons.geojson")); diff --git a/packages/turf-tag/package.json b/packages/turf-tag/package.json index 281ff527d2..7076049f1e 100644 --- a/packages/turf-tag/package.json +++ b/packages/turf-tag/package.json @@ -26,19 +26,19 @@ "data", "analysis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } diff --git a/packages/turf-tag/test.ts b/packages/turf-tag/test.ts index 0ef3658350..77d066d073 100644 --- a/packages/turf-tag/test.ts +++ b/packages/turf-tag/test.ts @@ -1,7 +1,10 @@ import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; -import { tag } from "./index"; +import { tag } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("tag", (t) => { const points = loadJsonFileSync( diff --git a/packages/turf-tesselate/bench.ts b/packages/turf-tesselate/bench.ts index 874888473c..41731d8a65 100644 --- a/packages/turf-tesselate/bench.ts +++ b/packages/turf-tesselate/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { polygon } from "@turf/helpers"; -import { tesselate } from "./index"; +import { tesselate } from "./index.js"; var poly = polygon([ [ diff --git a/packages/turf-tesselate/package.json b/packages/turf-tesselate/package.json index 14f0ef314b..4011445bd0 100644 --- a/packages/turf-tesselate/package.json +++ b/packages/turf-tesselate/package.json @@ -30,27 +30,26 @@ "polygon", "triangles" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -60,6 +59,7 @@ "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", "tape": "^5.7.2", diff --git a/packages/turf-tesselate/test.ts b/packages/turf-tesselate/test.ts index 173a9ed1e6..c5b07e1e8a 100644 --- a/packages/turf-tesselate/test.ts +++ b/packages/turf-tesselate/test.ts @@ -1,5 +1,5 @@ import test from "tape"; -import { tesselate } from "./index"; +import { tesselate } from "./index.js"; import { featureCollection as featurecollection } from "@turf/helpers"; import { point } from "@turf/helpers"; diff --git a/packages/turf-tin/bench.ts b/packages/turf-tin/bench.ts index 9109990515..cb61cf8ecb 100644 --- a/packages/turf-tin/bench.ts +++ b/packages/turf-tin/bench.ts @@ -1,7 +1,10 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import Benchmark from "benchmark"; -import { tin } from "./index"; +import { tin } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const points = JSON.parse( fs.readFileSync(path.join(__dirname, "test", "Points.json")) diff --git a/packages/turf-tin/package.json b/packages/turf-tin/package.json index 280960767a..5a67fe9ae6 100644 --- a/packages/turf-tin/package.json +++ b/packages/turf-tin/package.json @@ -21,19 +21,19 @@ "tin", "triangulate" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -48,7 +48,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-tin/test.ts b/packages/turf-tin/test.ts index f061b98ac6..e0785cc177 100644 --- a/packages/turf-tin/test.ts +++ b/packages/turf-tin/test.ts @@ -1,12 +1,16 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; -import { tin } from "./index"; +import { loadJsonFileSync } from "load-json-file"; +import { tin } from "./index.js"; -const points = require(path.join(__dirname, "test", "Points.json")); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +const points = loadJsonFileSync(path.join(__dirname, "test", "Points.json")); test("tin - z property", (t) => { - const expected = require(path.join(__dirname, "test", "Tin.json")); + const expected = loadJsonFileSync(path.join(__dirname, "test", "Tin.json")); const tinned = tin(points, "elevation"); t.equal(tinned.features[0].geometry.type, "Polygon"); t.equal(tinned.features.length, 24); @@ -21,7 +25,7 @@ test("tin - z property", (t) => { }); test("tin - z coordinate", (t) => { - const expected = require(path.join(__dirname, "test", "Tin-z.json")); + const expected = loadJsonFileSync(path.join(__dirname, "test", "Tin-z.json")); const tinned = tin(points); t.equal(tinned.features[0].geometry.type, "Polygon"); t.equal(tinned.features.length, 24); diff --git a/packages/turf-tin/types.ts b/packages/turf-tin/types.ts index 6d98a24020..2802fb41f8 100644 --- a/packages/turf-tin/types.ts +++ b/packages/turf-tin/types.ts @@ -1,5 +1,5 @@ import { featureCollection, point } from "@turf/helpers"; -import { tin } from "./index"; +import { tin } from "./index.js"; const points = featureCollection([ point([0, 0], { elevation: 20 }), diff --git a/packages/turf-transform-rotate/bench.ts b/packages/turf-transform-rotate/bench.ts index 56a94e94bf..a1aae93a35 100644 --- a/packages/turf-transform-rotate/bench.ts +++ b/packages/turf-transform-rotate/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { transformRotate as rotate } from "./index"; +import { transformRotate as rotate } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-transform-rotate/package.json b/packages/turf-transform-rotate/package.json index 74894e7062..77e8d238e4 100644 --- a/packages/turf-transform-rotate/package.json +++ b/packages/turf-transform-rotate/package.json @@ -26,27 +26,26 @@ "transformation", "rotate" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -54,10 +53,12 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-transform-rotate/test.ts b/packages/turf-transform-rotate/test.ts index 34d2373315..d74246ae0c 100644 --- a/packages/turf-transform-rotate/test.ts +++ b/packages/turf-transform-rotate/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { centroid } from "@turf/centroid"; @@ -12,7 +13,9 @@ import { featureCollection, geometryCollection, } from "@turf/helpers"; -import { transformRotate as rotate } from "./index"; +import { transformRotate as rotate } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-transform-rotate/types.ts b/packages/turf-transform-rotate/types.ts index 5c5e738a49..cb0f0af6fb 100644 --- a/packages/turf-transform-rotate/types.ts +++ b/packages/turf-transform-rotate/types.ts @@ -5,7 +5,7 @@ import { featureCollection, geometryCollection, } from "@turf/helpers"; -import { transformRotate as rotate } from "./index"; +import { transformRotate as rotate } from "./index.js"; const pt = point([15, 15]); const poly = polygon([ diff --git a/packages/turf-transform-scale/bench.ts b/packages/turf-transform-scale/bench.ts index de948532a8..9e29fe2f03 100644 --- a/packages/turf-transform-scale/bench.ts +++ b/packages/turf-transform-scale/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { transformScale as scale } from "./index"; +import { transformScale as scale } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-transform-scale/package.json b/packages/turf-transform-scale/package.json index 6546fe4407..625465481a 100644 --- a/packages/turf-transform-scale/package.json +++ b/packages/turf-transform-scale/package.json @@ -30,27 +30,26 @@ "zoom-in", "zoom-out" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -58,12 +57,14 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", "@turf/hex-grid": "workspace:^", "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-transform-scale/test.ts b/packages/turf-transform-scale/test.ts index 17f66d2ab1..c442ffe067 100644 --- a/packages/turf-transform-scale/test.ts +++ b/packages/turf-transform-scale/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { center } from "@turf/center"; @@ -17,7 +18,9 @@ import { geometryCollection, featureCollection, } from "@turf/helpers"; -import { transformScale as scale } from "./index"; +import { transformScale as scale } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-transform-scale/types.ts b/packages/turf-transform-scale/types.ts index 50a7a088e0..e4e3bcf0d8 100644 --- a/packages/turf-transform-scale/types.ts +++ b/packages/turf-transform-scale/types.ts @@ -1,6 +1,6 @@ import { LineString, Feature, Polygon } from "geojson"; import { lineString, polygon, featureCollection } from "@turf/helpers"; -import { transformScale as scale } from "./index"; +import { transformScale as scale } from "./index.js"; const line = lineString([ [0, 0], diff --git a/packages/turf-transform-translate/bench.ts b/packages/turf-transform-translate/bench.ts index 059c48eb44..6611b7e4f8 100644 --- a/packages/turf-transform-translate/bench.ts +++ b/packages/turf-transform-translate/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { transformTranslate as translate } from "./index"; +import { transformTranslate as translate } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-transform-translate/package.json b/packages/turf-transform-translate/package.json index 6a3c74fdac..1a042b7885 100644 --- a/packages/turf-transform-translate/package.json +++ b/packages/turf-transform-translate/package.json @@ -28,27 +28,26 @@ "move", "shift" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -56,10 +55,12 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-transform-translate/test.ts b/packages/turf-transform-translate/test.ts index 59c57e5d61..93b66d6d85 100644 --- a/packages/turf-transform-translate/test.ts +++ b/packages/turf-transform-translate/test.ts @@ -1,6 +1,7 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; @@ -10,7 +11,9 @@ import { geometryCollection, featureCollection, } from "@turf/helpers"; -import { transformTranslate as translate } from "./index"; +import { transformTranslate as translate } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-transform-translate/types.ts b/packages/turf-transform-translate/types.ts index 3490375107..303eebe68f 100644 --- a/packages/turf-transform-translate/types.ts +++ b/packages/turf-transform-translate/types.ts @@ -1,6 +1,6 @@ import { Point, Feature, Polygon } from "geojson"; import { point, polygon, featureCollection } from "@turf/helpers"; -import { transformTranslate as translate } from "./index"; +import { transformTranslate as translate } from "./index.js"; const pt = point([0, 0]); const poly = polygon([ diff --git a/packages/turf-triangle-grid/bench.ts b/packages/turf-triangle-grid/bench.ts index da656924d1..7f8ce4279e 100644 --- a/packages/turf-triangle-grid/bench.ts +++ b/packages/turf-triangle-grid/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import { triangleGrid as grid } from "./index"; +import { triangleGrid as grid } from "./index.js"; // prettier-ignore var bbox1 = [ diff --git a/packages/turf-triangle-grid/package.json b/packages/turf-triangle-grid/package.json index 1b16b3fadf..e28cc703d1 100644 --- a/packages/turf-triangle-grid/package.json +++ b/packages/turf-triangle-grid/package.json @@ -24,19 +24,19 @@ "analysis", "gis" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-triangle-grid/test.ts b/packages/turf-triangle-grid/test.ts index 05f35ce1b1..c66ba1caf6 100644 --- a/packages/turf-triangle-grid/test.ts +++ b/packages/turf-triangle-grid/test.ts @@ -1,11 +1,14 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; import { truncate } from "@turf/truncate"; -import { triangleGrid } from "./index"; +import { triangleGrid } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-triangle-grid/types.ts b/packages/turf-triangle-grid/types.ts index 46cc73d81a..33a7b1c88a 100644 --- a/packages/turf-triangle-grid/types.ts +++ b/packages/turf-triangle-grid/types.ts @@ -1,5 +1,5 @@ import { BBox } from "geojson"; -import { triangleGrid } from "./index"; +import { triangleGrid } from "./index.js"; // prettier-ignore const bbox: BBox = [ diff --git a/packages/turf-truncate/bench.ts b/packages/turf-truncate/bench.ts index 31b4145bb1..3bf283879d 100644 --- a/packages/turf-truncate/bench.ts +++ b/packages/turf-truncate/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { truncate } from "./index"; +import { truncate } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-truncate/package.json b/packages/turf-truncate/package.json index 40e81375f4..6d8627d6cc 100644 --- a/packages/turf-truncate/package.json +++ b/packages/turf-truncate/package.json @@ -25,19 +25,19 @@ "gis", "truncate" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -52,7 +52,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-truncate/test.ts b/packages/turf-truncate/test.ts index 003eab34bc..74c920d022 100644 --- a/packages/turf-truncate/test.ts +++ b/packages/turf-truncate/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import test from "tape"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point } from "@turf/helpers"; -import { truncate } from "./index"; +import { truncate } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-truncate/types.ts b/packages/turf-truncate/types.ts index 45b6384665..e67fac78f2 100644 --- a/packages/turf-truncate/types.ts +++ b/packages/turf-truncate/types.ts @@ -4,7 +4,7 @@ import { lineString, geometryCollection, } from "@turf/helpers"; -import { truncate } from "./index"; +import { truncate } from "./index.js"; const pt = point([120.1234567, 40.1234567]); const ptGeom = pt.geometry; diff --git a/packages/turf-union/bench.ts b/packages/turf-union/bench.ts index 8000991fde..a13a03b670 100644 --- a/packages/turf-union/bench.ts +++ b/packages/turf-union/bench.ts @@ -1,10 +1,13 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { union } from "./index"; +import { union } from "./index.js"; import { featureCollection } from "@turf/helpers"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + const directories = { in: path.join(__dirname, "test", "in") + path.sep, out: path.join(__dirname, "test", "out") + path.sep, diff --git a/packages/turf-union/package.json b/packages/turf-union/package.json index b12d6b1891..f06a9b8af9 100644 --- a/packages/turf-union/package.json +++ b/packages/turf-union/package.json @@ -20,19 +20,19 @@ "turf", "gif" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -47,7 +47,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-union/test.ts b/packages/turf-union/test.ts index eb1fed79cf..3127f3a63c 100644 --- a/packages/turf-union/test.ts +++ b/packages/turf-union/test.ts @@ -1,9 +1,12 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import { union } from "./index"; +import { union } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-union/types.ts b/packages/turf-union/types.ts index 6532f51644..fff2c5aed2 100644 --- a/packages/turf-union/types.ts +++ b/packages/turf-union/types.ts @@ -1,5 +1,5 @@ import { polygon, featureCollection } from "@turf/helpers"; -import { union } from "./index"; +import { union } from "./index.js"; const poly1 = polygon([ [ diff --git a/packages/turf-unkink-polygon/bench.ts b/packages/turf-unkink-polygon/bench.ts index fa32a248e5..b9689b6dee 100644 --- a/packages/turf-unkink-polygon/bench.ts +++ b/packages/turf-unkink-polygon/bench.ts @@ -1,8 +1,11 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import { unkinkPolygon as unkink } from "./index"; +import { unkinkPolygon as unkink } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-unkink-polygon/index.js b/packages/turf-unkink-polygon/index.js index ce3c6603f7..3a47207f12 100644 --- a/packages/turf-unkink-polygon/index.js +++ b/packages/turf-unkink-polygon/index.js @@ -1,6 +1,6 @@ import { flattenEach, featureEach } from "@turf/meta"; import { polygon, featureCollection } from "@turf/helpers"; -import { simplepolygon } from "./lib/simplepolygon"; +import { simplepolygon } from "./lib/simplepolygon.js"; /** * Takes a kinked polygon and returns a feature collection of polygons that have no kinks. diff --git a/packages/turf-unkink-polygon/package.json b/packages/turf-unkink-polygon/package.json index 86c71b999c..04a1e6eaaf 100644 --- a/packages/turf-unkink-polygon/package.json +++ b/packages/turf-unkink-polygon/package.json @@ -23,27 +23,26 @@ "polygon", "self-intersection" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -51,10 +50,12 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" + "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" }, "devDependencies": { "@turf/kinks": "workspace:^", + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", "npm-run-all": "^4.1.5", diff --git a/packages/turf-unkink-polygon/test.ts b/packages/turf-unkink-polygon/test.ts index c00c1b5eff..c01034ef8b 100644 --- a/packages/turf-unkink-polygon/test.ts +++ b/packages/turf-unkink-polygon/test.ts @@ -1,12 +1,15 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; import { featureCollection } from "@turf/helpers"; import { kinks } from "@turf/kinks"; -import { unkinkPolygon } from "./index"; +import { unkinkPolygon } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-unkink-polygon/types.ts b/packages/turf-unkink-polygon/types.ts index 0be7fa83ca..721492b8e1 100644 --- a/packages/turf-unkink-polygon/types.ts +++ b/packages/turf-unkink-polygon/types.ts @@ -1,5 +1,5 @@ import { polygon, multiPolygon } from "@turf/helpers"; -import { unkinkPolygon as unkink } from "./index"; +import { unkinkPolygon as unkink } from "./index.js"; const poly = polygon([ [ diff --git a/packages/turf-voronoi/bench.ts b/packages/turf-voronoi/bench.ts index decb658e94..d19e586e51 100644 --- a/packages/turf-voronoi/bench.ts +++ b/packages/turf-voronoi/bench.ts @@ -1,8 +1,11 @@ import Benchmark from "benchmark"; import path from "path"; +import { fileURLToPath } from "url"; import fs from "fs"; import { loadJsonFileSync } from "load-json-file"; -import { voronoi } from "./index"; +import { voronoi } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-voronoi/package.json b/packages/turf-voronoi/package.json index d8d148fe99..a870ce9dae 100644 --- a/packages/turf-voronoi/package.json +++ b/packages/turf-voronoi/package.json @@ -29,27 +29,26 @@ "polygons", "points" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } }, "sideEffects": false, "files": [ - "dist", - "index.d.ts" + "dist" ], "scripts": { "bench": "tsx bench.ts", @@ -59,6 +58,8 @@ "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", "load-json-file": "^7.0.1", diff --git a/packages/turf-voronoi/test.ts b/packages/turf-voronoi/test.ts index eab68d1eb8..d925a6b4d7 100644 --- a/packages/turf-voronoi/test.ts +++ b/packages/turf-voronoi/test.ts @@ -1,9 +1,12 @@ import test from "tape"; import { glob } from "glob"; import path from "path"; +import { fileURLToPath } from "url"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import { voronoi } from "./index"; +import { voronoi } from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); test("turf-voronoi", (t) => { glob diff --git a/packages/turf/package.json b/packages/turf/package.json index cb4b477981..e8967289bb 100644 --- a/packages/turf/package.json +++ b/packages/turf/package.json @@ -43,19 +43,19 @@ "jenks", "sample" ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", - "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.js", + "types": "dist/esm/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" }, "require": { - "types": "./dist/cjs/index.d.ts", + "types": "./dist/cjs/index.d.cts", "default": "./dist/cjs/index.cjs" } } @@ -64,7 +64,6 @@ "sideEffects": false, "files": [ "dist", - "index.d.ts", "turf.min.js" ], "scripts": { diff --git a/packages/turf/test.ts b/packages/turf/test.ts index 6798691abd..7da75dad40 100644 --- a/packages/turf/test.ts +++ b/packages/turf/test.ts @@ -1,10 +1,13 @@ import fs from "fs"; import path from "path"; +import { fileURLToPath } from "url"; import { glob } from "glob"; import test from "tape"; import camelCase from "camelcase"; import documentation from "documentation"; -import * as turf from "./index"; +import * as turf from "./index.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Helpers const directory = path.join(__dirname, ".."); @@ -218,7 +221,7 @@ test("turf -- parsing dependencies from index.js", (t) => { // Test for missing modules test("turf -- missing modules", (t) => { const files = { - typescript: fs.readFileSync(path.join(__dirname, "dist/cjs/index.d.ts")), + typescript: fs.readFileSync(path.join(__dirname, "dist/cjs/index.d.cts")), modules: fs.readFileSync(path.join(__dirname, "dist/cjs/index.cjs")), }; @@ -327,8 +330,8 @@ const turfModulesPath = path.join(__dirname, "..", "turf-*", "index.js"); const turfTypescriptPath = path.join(__dirname, "..", "turf-*", "index.d.ts"); // Test Strings -const requireString = `const test = require('tape'); -const turf = require('./dist/cjs/index.cjs'); +const requireString = `import test from 'tape'; +import * as turf from './dist/esm/index.js'; `; /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb2b3ff97f..fb5a094f3c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1607,6 +1607,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -2100,6 +2106,9 @@ importers: '@types/benchmark': specifier: ^2.1.5 version: 2.1.5 + '@types/rbush': + specifier: ^3.0.2 + version: 3.0.3 '@types/tape': specifier: ^4.2.32 version: 4.13.4 @@ -2972,6 +2981,12 @@ importers: '@turf/random': specifier: workspace:^ version: link:../turf-random + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -3009,6 +3024,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -3162,6 +3183,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -3578,6 +3605,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -3661,6 +3694,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -3808,6 +3847,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -3851,6 +3896,12 @@ importers: '@turf/length': specifier: workspace:^ version: link:../turf-length + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -3903,6 +3954,12 @@ importers: specifier: workspace:^ version: link:../turf-truncate devDependencies: + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -3983,6 +4040,12 @@ importers: specifier: ^0.15.3 version: 0.15.3 devDependencies: + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -4017,6 +4080,9 @@ importers: '@turf/random': specifier: workspace:^ version: link:../turf-random + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -4048,6 +4114,9 @@ importers: specifier: workspace:^ version: link:../turf-helpers devDependencies: + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -4201,6 +4270,9 @@ importers: benchmark: specifier: ^2.1.4 version: 2.1.4 + load-json-file: + specifier: ^7.0.1 + version: 7.0.1 npm-run-all: specifier: ^4.1.5 version: 4.1.5 @@ -4216,6 +4288,9 @@ importers: typescript: specifier: ^5.2.2 version: 5.3.3 + write-json-file: + specifier: ^5.0.0 + version: 5.0.0 packages/turf-nearest-point-on-line: dependencies: @@ -4473,6 +4548,9 @@ importers: typescript: specifier: ^5.2.2 version: 5.3.3 + write-json-file: + specifier: ^5.0.0 + version: 5.0.0 packages/turf-point-to-line-distance: dependencies: @@ -5475,6 +5553,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -5552,6 +5636,9 @@ importers: specifier: ^2.2.4 version: 2.2.4 devDependencies: + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -5632,6 +5719,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -5696,6 +5789,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -5739,6 +5838,12 @@ importers: '@turf/truncate': specifier: workspace:^ version: link:../turf-truncate + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -5926,6 +6031,12 @@ importers: '@turf/kinks': specifier: workspace:^ version: link:../turf-kinks + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -5963,6 +6074,12 @@ importers: specifier: 1.1.2 version: 1.1.2 devDependencies: + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -7235,6 +7352,15 @@ packages: kuler: 2.0.0 dev: true + /@esbuild/aix-ppc64@0.19.11: + resolution: {integrity: sha512-FnzU0LyE3ySQk7UntJO4+qIiQgI7KoODnZg5xzXIrFJlKd2P2gwHsHY4927xj9y5PJmJSzULiUCWmv7iWnNa7g==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-arm64@0.18.20: resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} engines: {node: '>=12'} @@ -7244,8 +7370,8 @@ packages: dev: true optional: true - /@esbuild/android-arm64@0.19.9: - resolution: {integrity: sha512-q4cR+6ZD0938R19MyEW3jEsMzbb/1rulLXiNAJQADD/XYp7pT+rOS5JGxvpRW8dFDEfjW4wLgC/3FXIw4zYglQ==} + /@esbuild/android-arm64@0.19.11: + resolution: {integrity: sha512-aiu7K/5JnLj//KOnOfEZ0D90obUkRzDMyqd/wNAUQ34m4YUPVhRZpnqKV9uqDGxT7cToSDnIHsGooyIczu9T+Q==} engines: {node: '>=12'} cpu: [arm64] os: [android] @@ -7262,8 +7388,8 @@ packages: dev: true optional: true - /@esbuild/android-arm@0.19.9: - resolution: {integrity: sha512-jkYjjq7SdsWuNI6b5quymW0oC83NN5FdRPuCbs9HZ02mfVdAP8B8eeqLSYU3gb6OJEaY5CQabtTFbqBf26H3GA==} + /@esbuild/android-arm@0.19.11: + resolution: {integrity: sha512-5OVapq0ClabvKvQ58Bws8+wkLCV+Rxg7tUVbo9xu034Nm536QTII4YzhaFriQ7rMrorfnFKUsArD2lqKbFY4vw==} engines: {node: '>=12'} cpu: [arm] os: [android] @@ -7280,8 +7406,8 @@ packages: dev: true optional: true - /@esbuild/android-x64@0.19.9: - resolution: {integrity: sha512-KOqoPntWAH6ZxDwx1D6mRntIgZh9KodzgNOy5Ebt9ghzffOk9X2c1sPwtM9P+0eXbefnDhqYfkh5PLP5ULtWFA==} + /@esbuild/android-x64@0.19.11: + resolution: {integrity: sha512-eccxjlfGw43WYoY9QgB82SgGgDbibcqyDTlk3l3C0jOVHKxrjdc9CTwDUQd0vkvYg5um0OH+GpxYvp39r+IPOg==} engines: {node: '>=12'} cpu: [x64] os: [android] @@ -7298,8 +7424,8 @@ packages: dev: true optional: true - /@esbuild/darwin-arm64@0.19.9: - resolution: {integrity: sha512-KBJ9S0AFyLVx2E5D8W0vExqRW01WqRtczUZ8NRu+Pi+87opZn5tL4Y0xT0mA4FtHctd0ZgwNoN639fUUGlNIWw==} + /@esbuild/darwin-arm64@0.19.11: + resolution: {integrity: sha512-ETp87DRWuSt9KdDVkqSoKoLFHYTrkyz2+65fj9nfXsaV3bMhTCjtQfw3y+um88vGRKRiF7erPrh/ZuIdLUIVxQ==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] @@ -7316,8 +7442,8 @@ packages: dev: true optional: true - /@esbuild/darwin-x64@0.19.9: - resolution: {integrity: sha512-vE0VotmNTQaTdX0Q9dOHmMTao6ObjyPm58CHZr1UK7qpNleQyxlFlNCaHsHx6Uqv86VgPmR4o2wdNq3dP1qyDQ==} + /@esbuild/darwin-x64@0.19.11: + resolution: {integrity: sha512-fkFUiS6IUK9WYUO/+22omwetaSNl5/A8giXvQlcinLIjVkxwTLSktbF5f/kJMftM2MJp9+fXqZ5ezS7+SALp4g==} engines: {node: '>=12'} cpu: [x64] os: [darwin] @@ -7334,8 +7460,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-arm64@0.19.9: - resolution: {integrity: sha512-uFQyd/o1IjiEk3rUHSwUKkqZwqdvuD8GevWF065eqgYfexcVkxh+IJgwTaGZVu59XczZGcN/YMh9uF1fWD8j1g==} + /@esbuild/freebsd-arm64@0.19.11: + resolution: {integrity: sha512-lhoSp5K6bxKRNdXUtHoNc5HhbXVCS8V0iZmDvyWvYq9S5WSfTIHU2UGjcGt7UeS6iEYp9eeymIl5mJBn0yiuxA==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] @@ -7352,8 +7478,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-x64@0.19.9: - resolution: {integrity: sha512-WMLgWAtkdTbTu1AWacY7uoj/YtHthgqrqhf1OaEWnZb7PQgpt8eaA/F3LkV0E6K/Lc0cUr/uaVP/49iE4M4asA==} + /@esbuild/freebsd-x64@0.19.11: + resolution: {integrity: sha512-JkUqn44AffGXitVI6/AbQdoYAq0TEullFdqcMY/PCUZ36xJ9ZJRtQabzMA+Vi7r78+25ZIBosLTOKnUXBSi1Kw==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] @@ -7370,8 +7496,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm64@0.19.9: - resolution: {integrity: sha512-PiPblfe1BjK7WDAKR1Cr9O7VVPqVNpwFcPWgfn4xu0eMemzRp442hXyzF/fSwgrufI66FpHOEJk0yYdPInsmyQ==} + /@esbuild/linux-arm64@0.19.11: + resolution: {integrity: sha512-LneLg3ypEeveBSMuoa0kwMpCGmpu8XQUh+mL8XXwoYZ6Be2qBnVtcDI5azSvh7vioMDhoJFZzp9GWp9IWpYoUg==} engines: {node: '>=12'} cpu: [arm64] os: [linux] @@ -7388,8 +7514,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm@0.19.9: - resolution: {integrity: sha512-C/ChPohUYoyUaqn1h17m/6yt6OB14hbXvT8EgM1ZWaiiTYz7nWZR0SYmMnB5BzQA4GXl3BgBO1l8MYqL/He3qw==} + /@esbuild/linux-arm@0.19.11: + resolution: {integrity: sha512-3CRkr9+vCV2XJbjwgzjPtO8T0SZUmRZla+UL1jw+XqHZPkPgZiyWvbDvl9rqAN8Zl7qJF0O/9ycMtjU67HN9/Q==} engines: {node: '>=12'} cpu: [arm] os: [linux] @@ -7406,8 +7532,8 @@ packages: dev: true optional: true - /@esbuild/linux-ia32@0.19.9: - resolution: {integrity: sha512-f37i/0zE0MjDxijkPSQw1CO/7C27Eojqb+r3BbHVxMLkj8GCa78TrBZzvPyA/FNLUMzP3eyHCVkAopkKVja+6Q==} + /@esbuild/linux-ia32@0.19.11: + resolution: {integrity: sha512-caHy++CsD8Bgq2V5CodbJjFPEiDPq8JJmBdeyZ8GWVQMjRD0sU548nNdwPNvKjVpamYYVL40AORekgfIubwHoA==} engines: {node: '>=12'} cpu: [ia32] os: [linux] @@ -7424,8 +7550,8 @@ packages: dev: true optional: true - /@esbuild/linux-loong64@0.19.9: - resolution: {integrity: sha512-t6mN147pUIf3t6wUt3FeumoOTPfmv9Cc6DQlsVBpB7eCpLOqQDyWBP1ymXn1lDw4fNUSb/gBcKAmvTP49oIkaA==} + /@esbuild/linux-loong64@0.19.11: + resolution: {integrity: sha512-ppZSSLVpPrwHccvC6nQVZaSHlFsvCQyjnvirnVjbKSHuE5N24Yl8F3UwYUUR1UEPaFObGD2tSvVKbvR+uT1Nrg==} engines: {node: '>=12'} cpu: [loong64] os: [linux] @@ -7442,8 +7568,8 @@ packages: dev: true optional: true - /@esbuild/linux-mips64el@0.19.9: - resolution: {integrity: sha512-jg9fujJTNTQBuDXdmAg1eeJUL4Jds7BklOTkkH80ZgQIoCTdQrDaHYgbFZyeTq8zbY+axgptncko3v9p5hLZtw==} + /@esbuild/linux-mips64el@0.19.11: + resolution: {integrity: sha512-B5x9j0OgjG+v1dF2DkH34lr+7Gmv0kzX6/V0afF41FkPMMqaQ77pH7CrhWeR22aEeHKaeZVtZ6yFwlxOKPVFyg==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] @@ -7460,8 +7586,8 @@ packages: dev: true optional: true - /@esbuild/linux-ppc64@0.19.9: - resolution: {integrity: sha512-tkV0xUX0pUUgY4ha7z5BbDS85uI7ABw3V1d0RNTii7E9lbmV8Z37Pup2tsLV46SQWzjOeyDi1Q7Wx2+QM8WaCQ==} + /@esbuild/linux-ppc64@0.19.11: + resolution: {integrity: sha512-MHrZYLeCG8vXblMetWyttkdVRjQlQUb/oMgBNurVEnhj4YWOr4G5lmBfZjHYQHHN0g6yDmCAQRR8MUHldvvRDA==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] @@ -7478,8 +7604,8 @@ packages: dev: true optional: true - /@esbuild/linux-riscv64@0.19.9: - resolution: {integrity: sha512-DfLp8dj91cufgPZDXr9p3FoR++m3ZJ6uIXsXrIvJdOjXVREtXuQCjfMfvmc3LScAVmLjcfloyVtpn43D56JFHg==} + /@esbuild/linux-riscv64@0.19.11: + resolution: {integrity: sha512-f3DY++t94uVg141dozDu4CCUkYW+09rWtaWfnb3bqe4w5NqmZd6nPVBm+qbz7WaHZCoqXqHz5p6CM6qv3qnSSQ==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] @@ -7496,8 +7622,8 @@ packages: dev: true optional: true - /@esbuild/linux-s390x@0.19.9: - resolution: {integrity: sha512-zHbglfEdC88KMgCWpOl/zc6dDYJvWGLiUtmPRsr1OgCViu3z5GncvNVdf+6/56O2Ca8jUU+t1BW261V6kp8qdw==} + /@esbuild/linux-s390x@0.19.11: + resolution: {integrity: sha512-A5xdUoyWJHMMlcSMcPGVLzYzpcY8QP1RtYzX5/bS4dvjBGVxdhuiYyFwp7z74ocV7WDc0n1harxmpq2ePOjI0Q==} engines: {node: '>=12'} cpu: [s390x] os: [linux] @@ -7514,8 +7640,8 @@ packages: dev: true optional: true - /@esbuild/linux-x64@0.19.9: - resolution: {integrity: sha512-JUjpystGFFmNrEHQnIVG8hKwvA2DN5o7RqiO1CVX8EN/F/gkCjkUMgVn6hzScpwnJtl2mPR6I9XV1oW8k9O+0A==} + /@esbuild/linux-x64@0.19.11: + resolution: {integrity: sha512-grbyMlVCvJSfxFQUndw5mCtWs5LO1gUlwP4CDi4iJBbVpZcqLVT29FxgGuBJGSzyOxotFG4LoO5X+M1350zmPA==} engines: {node: '>=12'} cpu: [x64] os: [linux] @@ -7532,8 +7658,8 @@ packages: dev: true optional: true - /@esbuild/netbsd-x64@0.19.9: - resolution: {integrity: sha512-GThgZPAwOBOsheA2RUlW5UeroRfESwMq/guy8uEe3wJlAOjpOXuSevLRd70NZ37ZrpO6RHGHgEHvPg1h3S1Jug==} + /@esbuild/netbsd-x64@0.19.11: + resolution: {integrity: sha512-13jvrQZJc3P230OhU8xgwUnDeuC/9egsjTkXN49b3GcS5BKvJqZn86aGM8W9pd14Kd+u7HuFBMVtrNGhh6fHEQ==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] @@ -7550,8 +7676,8 @@ packages: dev: true optional: true - /@esbuild/openbsd-x64@0.19.9: - resolution: {integrity: sha512-Ki6PlzppaFVbLnD8PtlVQfsYw4S9n3eQl87cqgeIw+O3sRr9IghpfSKY62mggdt1yCSZ8QWvTZ9jo9fjDSg9uw==} + /@esbuild/openbsd-x64@0.19.11: + resolution: {integrity: sha512-ysyOGZuTp6SNKPE11INDUeFVVQFrhcNDVUgSQVDzqsqX38DjhPEPATpid04LCoUr2WXhQTEZ8ct/EgJCUDpyNw==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] @@ -7568,8 +7694,8 @@ packages: dev: true optional: true - /@esbuild/sunos-x64@0.19.9: - resolution: {integrity: sha512-MLHj7k9hWh4y1ddkBpvRj2b9NCBhfgBt3VpWbHQnXRedVun/hC7sIyTGDGTfsGuXo4ebik2+3ShjcPbhtFwWDw==} + /@esbuild/sunos-x64@0.19.11: + resolution: {integrity: sha512-Hf+Sad9nVwvtxy4DXCZQqLpgmRTQqyFyhT3bZ4F2XlJCjxGmRFF0Shwn9rzhOYRB61w9VMXUkxlBy56dk9JJiQ==} engines: {node: '>=12'} cpu: [x64] os: [sunos] @@ -7586,8 +7712,8 @@ packages: dev: true optional: true - /@esbuild/win32-arm64@0.19.9: - resolution: {integrity: sha512-GQoa6OrQ8G08guMFgeXPH7yE/8Dt0IfOGWJSfSH4uafwdC7rWwrfE6P9N8AtPGIjUzdo2+7bN8Xo3qC578olhg==} + /@esbuild/win32-arm64@0.19.11: + resolution: {integrity: sha512-0P58Sbi0LctOMOQbpEOvOL44Ne0sqbS0XWHMvvrg6NE5jQ1xguCSSw9jQeUk2lfrXYsKDdOe6K+oZiwKPilYPQ==} engines: {node: '>=12'} cpu: [arm64] os: [win32] @@ -7604,8 +7730,8 @@ packages: dev: true optional: true - /@esbuild/win32-ia32@0.19.9: - resolution: {integrity: sha512-UOozV7Ntykvr5tSOlGCrqU3NBr3d8JqPes0QWN2WOXfvkWVGRajC+Ym0/Wj88fUgecUCLDdJPDF0Nna2UK3Qtg==} + /@esbuild/win32-ia32@0.19.11: + resolution: {integrity: sha512-6YOrWS+sDJDmshdBIQU+Uoyh7pQKrdykdefC1avn76ss5c+RN6gut3LZA4E2cH5xUEp5/cA0+YxRaVtRAb0xBg==} engines: {node: '>=12'} cpu: [ia32] os: [win32] @@ -7622,8 +7748,8 @@ packages: dev: true optional: true - /@esbuild/win32-x64@0.19.9: - resolution: {integrity: sha512-oxoQgglOP7RH6iasDrhY+R/3cHrfwIDvRlT4CGChflq6twk8iENeVvMJjmvBb94Ik1Z+93iGO27err7w6l54GQ==} + /@esbuild/win32-x64@0.19.11: + resolution: {integrity: sha512-vfkhltrjCAb603XaFhqhAF4LGDi2M4OrCRrFusyQ+iTLQ/o60QQXxc9cZC/FFpihBI9N1Grn6SMKVJ4KP7Fuiw==} engines: {node: '>=12'} cpu: [x64] os: [win32] @@ -9553,13 +9679,13 @@ packages: run-applescript: 5.0.0 dev: true - /bundle-require@4.0.2(esbuild@0.19.9): + /bundle-require@4.0.2(esbuild@0.19.11): resolution: {integrity: sha512-jwzPOChofl67PSTW2SGubV9HBQAhhR2i6nskiOThauo9dzwDUgOWQScFVaJkjEfYX+UXiD+LEx8EblQMc2wIag==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} peerDependencies: esbuild: '>=0.17' dependencies: - esbuild: 0.19.9 + esbuild: 0.19.11 load-tsconfig: 0.2.5 dev: true @@ -11042,34 +11168,35 @@ packages: '@esbuild/win32-x64': 0.18.20 dev: true - /esbuild@0.19.9: - resolution: {integrity: sha512-U9CHtKSy+EpPsEBa+/A2gMs/h3ylBC0H0KSqIg7tpztHerLi6nrrcoUJAkNCEPumx8yJ+Byic4BVwHgRbN0TBg==} + /esbuild@0.19.11: + resolution: {integrity: sha512-HJ96Hev2hX/6i5cDVwcqiJBBtuo9+FeIJOtZ9W1kA5M6AMJRHUZlpYZ1/SbEwtO0ioNAW8rUooVpC/WehY2SfA==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/android-arm': 0.19.9 - '@esbuild/android-arm64': 0.19.9 - '@esbuild/android-x64': 0.19.9 - '@esbuild/darwin-arm64': 0.19.9 - '@esbuild/darwin-x64': 0.19.9 - '@esbuild/freebsd-arm64': 0.19.9 - '@esbuild/freebsd-x64': 0.19.9 - '@esbuild/linux-arm': 0.19.9 - '@esbuild/linux-arm64': 0.19.9 - '@esbuild/linux-ia32': 0.19.9 - '@esbuild/linux-loong64': 0.19.9 - '@esbuild/linux-mips64el': 0.19.9 - '@esbuild/linux-ppc64': 0.19.9 - '@esbuild/linux-riscv64': 0.19.9 - '@esbuild/linux-s390x': 0.19.9 - '@esbuild/linux-x64': 0.19.9 - '@esbuild/netbsd-x64': 0.19.9 - '@esbuild/openbsd-x64': 0.19.9 - '@esbuild/sunos-x64': 0.19.9 - '@esbuild/win32-arm64': 0.19.9 - '@esbuild/win32-ia32': 0.19.9 - '@esbuild/win32-x64': 0.19.9 + '@esbuild/aix-ppc64': 0.19.11 + '@esbuild/android-arm': 0.19.11 + '@esbuild/android-arm64': 0.19.11 + '@esbuild/android-x64': 0.19.11 + '@esbuild/darwin-arm64': 0.19.11 + '@esbuild/darwin-x64': 0.19.11 + '@esbuild/freebsd-arm64': 0.19.11 + '@esbuild/freebsd-x64': 0.19.11 + '@esbuild/linux-arm': 0.19.11 + '@esbuild/linux-arm64': 0.19.11 + '@esbuild/linux-ia32': 0.19.11 + '@esbuild/linux-loong64': 0.19.11 + '@esbuild/linux-mips64el': 0.19.11 + '@esbuild/linux-ppc64': 0.19.11 + '@esbuild/linux-riscv64': 0.19.11 + '@esbuild/linux-s390x': 0.19.11 + '@esbuild/linux-x64': 0.19.11 + '@esbuild/netbsd-x64': 0.19.11 + '@esbuild/openbsd-x64': 0.19.11 + '@esbuild/sunos-x64': 0.19.11 + '@esbuild/win32-arm64': 0.19.11 + '@esbuild/win32-ia32': 0.19.11 + '@esbuild/win32-x64': 0.19.11 dev: true /escalade@3.1.1: @@ -16684,11 +16811,11 @@ packages: typescript: optional: true dependencies: - bundle-require: 4.0.2(esbuild@0.19.9) + bundle-require: 4.0.2(esbuild@0.19.11) cac: 6.7.14 chokidar: 3.5.3 debug: 4.3.4 - esbuild: 0.19.9 + esbuild: 0.19.11 execa: 5.1.1 globby: 11.1.0 joycon: 3.1.1 diff --git a/tsup.config.ts b/tsup.config.ts index 958b14bc8a..9ff2aa452b 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -3,7 +3,7 @@ import { defineConfig, type Options } from "tsup"; const baseOptions: Options = { clean: true, dts: true, - entry: ["index.?s"], + entry: ["index.?s"], // while we have a mix of TS and JS packages minify: false, skipNodeModulesBundle: true, sourcemap: true, @@ -20,7 +20,6 @@ export default [ ...baseOptions, outDir: "dist/cjs", format: "cjs", - outExtension: () => ({ js: ".cjs" }), }), defineConfig({ ...baseOptions,