Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4bc86a0
Minimal changes required to have existing ESM+CJS build process compl…
smallsaucepan Dec 20, 2025
6da37b9
Added rules to monorepolint to generate per package tsconfig.json and…
smallsaucepan Dec 22, 2025
cfc3c7d
Split @turf/turf build into build and rollup, and moved rollup to the…
smallsaucepan Dec 22, 2025
8b9b2a4
Auto generated (by mrl) changes to existing tsconfig.json and package…
smallsaucepan Dec 22, 2025
26162d8
Auto generated (by mrl) NEW tsconfig.build.json, tsconfig.types.json,…
smallsaucepan Dec 22, 2025
9892d32
Removed now defunct (I think) seperate build tsconfig and tsup config…
smallsaucepan Dec 30, 2025
636eaf0
Merge branch 'Turfjs:master' into dev-without-build
smallsaucepan Dec 31, 2025
5caa61d
WIP.
smallsaucepan Jan 2, 2026
b3f2903
Merge remote-tracking branch 'refs/remotes/origin/dev-without-build' …
smallsaucepan Jan 2, 2026
02a8b4d
Merge branch 'master' into dev-without-build
smallsaucepan Jan 2, 2026
2f579b3
Migrate @turf/buffer to TypeScript, ignoring errors
mfedderly Jan 5, 2026
7c4b76f
Merge remote-tracking branch 'upstream/mf/buffer-ts-basic' into dev-w…
smallsaucepan Jan 11, 2026
7847682
Merge branch 'master' into dev-without-build
smallsaucepan Jan 11, 2026
1ae24d0
Retired tsup for JS generation. Instead using tsc with two configs in…
smallsaucepan Jan 12, 2026
c1e9d9f
Being explicit about when we are exporting types. Related to enabling…
smallsaucepan Jan 12, 2026
7ed0c48
Merge branch 'master' into dev-without-build
smallsaucepan Apr 29, 2026
c289319
Refactor build targets in normal packages to build (esm only) and pre…
smallsaucepan Apr 30, 2026
5acee45
Work in progress. Utilise eslint and prettier built in caching. Test …
smallsaucepan May 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ node_modules

.nx/
.cursor/rules/nx-rules.mdc
.eslintcache
.github/instructions/nx.instructions.md
130 changes: 55 additions & 75 deletions .monorepolint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
import * as path from "node:path";
import { existsSync } from "node:fs";
import * as fs from "node:fs/promises";
Expand All @@ -10,13 +9,15 @@ import {
packageScript,
requireDependency,
REMOVE,
standardTsconfig,
fileContents,
} from "@monorepolint/rules";

const PACKAGES = []; // packages that aren't @turf/turf
const MAIN_PACKAGE = "@turf/turf";
const AGG_PACKAGE = "@turf/turf"; // aggregate package utilising rollup

const TAPE_PACKAGES = []; // packages that have tape tests
const TYPES_PACKAGES = []; // packages that have types tests
const TAPE_PACKAGES = []; // packages with tape tests
const TYPES_PACKAGES = []; // packages with types tests
const TSTYCHE_PACKAGES = []; // packages that use tstyche for type tests.

// iterate all the packages and figure out what buckets everything falls into
Expand All @@ -32,7 +33,7 @@ for (const pk of await fs.readdir(packagesPath)) {

PACKAGES.push(name);

if (existsSync(path.join(pk, "test.js"))) {
if (existsSync(path.join(pk, "test.ts"))) {
TAPE_PACKAGES.push(name);
}

Expand Down Expand Up @@ -83,23 +84,28 @@ export default {
}),
alphabeticalDependencies({ includeWorkspaceRoot: true }),
alphabeticalScripts({ includeWorkspaceRoot: true }),
standardTsconfig({
options: { templateFile: "./templates/package/tsconfig.json" },
includePackages: [...PACKAGES, AGG_PACKAGE],
}),
standardTsconfig({
options: {
file: "tsconfig.cjs.json",
templateFile: "./templates/package/tsconfig.cjs.json",
},
includePackages: [...PACKAGES, AGG_PACKAGE],
}),
packageEntry({
options: {
entries: {
type: "module",
main: "dist/cjs/index.cjs",
main: "dist/cjs/index.js",
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", "turf.min.js"],
exports: {
"./package.json": "./package.json",
".": {
Expand All @@ -108,107 +114,89 @@ export default {
default: "./dist/esm/index.js",
},
require: {
types: "./dist/cjs/index.d.cts",
default: "./dist/cjs/index.cjs",
types: "./dist/cjs/index.d.ts",
default: "./dist/cjs/index.js",
},
},
},
},
},
includePackages: [MAIN_PACKAGE],
includePackages: PACKAGES,
}),

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",
},
exports: {
"./package.json": "./package.json",
".": {
import: {
types: "./dist/esm/index.d.ts",
default: "./dist/esm/index.js",
},
require: {
types: "./dist/cjs/index.d.cts",
default: "./dist/cjs/index.cjs",
},
},
},
files: ["dist"],
},
},
includePackages: PACKAGES,
excludePackages: [AGG_PACKAGE],
}),

packageEntry({
options: {
entries: {
files: ["dist"],
// @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
// Ex ample of a URL that will keep working: https://unpkg.com/@turf/turf
browser: "turf.min.js",
files: ["dist", "turf.min.js"],
},
},
includePackages: PACKAGES,
includePackages: [AGG_PACKAGE],
}),

packageEntry({
options: {
entries: {
funding: "https://opencollective.com/turf",
},
},
}),

packageScript({
options: {
scripts: {
docs: REMOVE,
rollup: "rollup -c rollup.config.js",
test: "pnpm run /test:.*/",
},
},
excludePackages: [MAIN_PACKAGE],
includePackages: [AGG_PACKAGE],
}),

packageScript({
options: {
scripts: {
build: "tsup --config ../../tsup.config.ts",
build: "tsc -b",
"build:cjs": REMOVE,
"build:esm": REMOVE,
prepack: "tsc -b tsconfig.cjs.json",
},
},
includePackages: PACKAGES,
includePackages: [...PACKAGES, AGG_PACKAGE],
}),

packageScript({
options: {
scripts: {
build:
"tsup --config ../../tsup.config.ts && rollup -c rollup.config.js",
bench: "tsx bench.ts",
"test:tape": "tsx test.ts",
},
},
includePackages: [MAIN_PACKAGE],
includePackages: TAPE_PACKAGES,
}),

packageScript({
options: {
scripts: {
bench: "tsx bench.ts",
"test:tape": "tsx test.ts",
"test:types": "tsc --project tsconfig.types.json",
},
},
includePackages: TAPE_PACKAGES,
includePackages: TYPES_PACKAGES,
}),

packageScript({
fileContents({
options: {
scripts: {
"test:types":
"tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts",
},
file: "tsconfig.types.json",
templateFile: "./templates/package/tsconfig.types.json",
},
includePackages: TYPES_PACKAGES,
}),
Expand All @@ -224,28 +212,29 @@ export default {

requireDependency({
options: {
dependencies: {
"@types/geojson": "catalog:",
tslib: "catalog:",
},
devDependencies: {
"@types/benchmark": "catalog:",
"@types/tape": "catalog:",
benchmark: "catalog:",
glob: REMOVE,
tape: "catalog:",
tsup: "catalog:",
tsx: "catalog:",
typescript: "catalog:",
},
},
includePackages: PACKAGES,
includePackages: [...PACKAGES, AGG_PACKAGE],
}),

requireDependency({
options: {
dependencies: {
tslib: "catalog:",
},
devDependencies: {
"@types/benchmark": "catalog:",
"@types/tape": "catalog:",
typescript: "catalog:",
glob: REMOVE,
},
},
// Keep glob for @turf/turf test for now. Remove after refactoring.
includePackages: PACKAGES,
}),

Expand All @@ -257,14 +246,5 @@ export default {
},
includePackages: TSTYCHE_PACKAGES,
}),

requireDependency({
options: {
dependencies: {
"@types/geojson": "catalog:",
},
},
includePackages: [MAIN_PACKAGE, ...PACKAGES],
}),
],
};
8 changes: 7 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ pnpm-lock.yaml

/.nx/cache

/.nx/workspace-data
/.nx/workspace-data

# Auto generated by mrl, which produces a slightly clashing format.
tsconfig.json
tsconfig.cjs.json
tsconfig.shared.json
tsconfig.types.json
Comment thread
mfedderly marked this conversation as resolved.
25 changes: 6 additions & 19 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
{
"analytics": false,
"tui": {
"enabled": false
},
"namedInputs": {
"default": [
"{workspaceRoot}/pnpm-lock.yaml",
"{workspaceRoot}/tsconfig.shared.json",
"{projectRoot}/package.json",
"{projectRoot}/tsconfig.json"
],
"sources": ["{projectRoot}/index.{js,ts}", "{projectRoot}/lib/**"]
"sources": ["{projectRoot}/index.ts", "{projectRoot}/lib/**"]
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": [
"default",
"sources",
"{workspaceRoot}/tsup.config.ts",
"{projectRoot}/index.d.ts",
"{projectRoot}/rollup.config.cjs"
],
"outputs": ["{projectRoot}/dist"],
"cache": true
},
"test": {
"inputs": [
"default",
Expand All @@ -29,12 +21,7 @@
"{projectRoot}/test/**",
"{projectRoot}/types.ts"
],
"dependsOn": ["build"],
"cache": true
},
"last-checks": {
"inputs": ["default", "{projectRoot}/test.ts"],
"dependsOn": ["build", "^last-checks"],
"dependsOn": [],
"cache": true
}
}
Expand Down
27 changes: 18 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@
"private": true,
"funding": "https://opencollective.com/turf",
"scripts": {
"build": "tsc -b",
"dependencies": "tsc -b",
"docs": "node ./scripts/generate-readmes.mts",
"escheck": "pnpm run /escheck:.*/",
"escheck:cjs": "es-check es8 packages/*/dist/cjs/index.js packages/turf/turf.min.js",
"escheck:esm": "es-check --module es8 packages/*/dist/esm/index.js",
"escheck:web": "es-check es5 packages/turf/turf.min.js",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lmao we're still shipping es5 turf.min.js. That should definitely get bumped way forward.
#2989

"lint": "pnpm run /lint:.*/",
"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.js",
"lint:escheck-web": "es-check es5 packages/turf/turf.min.js",
"lint:eslint": "eslint packages",
"lint:eslint": "eslint --cache packages",
"lint:mrl": "mrl check",
"lint:prettier": "prettier --check .",
"lint:prettier": "prettier --cache --check .",
"preinstall": "npx only-allow pnpm",
"prepare": "husky && lerna run build",
"test": "pnpm run lint && lerna run test && lerna run --scope @turf/turf last-checks"
"prepack": "tsc -b ./tsconfig.cjs.json && tsx scripts/cjs-package-json.ts && pnpm run --filter @turf/turf rollup",
"prepare": "husky && tsc -b",
"prepublishOnly": "pnpm run lint && pnpm run escheck && pnpm run --filter @turf/turf last-checks",
"release": "pnpm run test:release && pnpm publish -r",
"test": "pnpm exec nx run-many -t test",
"test:release": "pnpm run lint && pnpm run escheck && pnpm run --filter @turf/turf last-checks",
"watch": "tsc -b --watch"
},
"lint-staged": {
"package.json": [
Expand All @@ -22,7 +30,7 @@
"**/*.{js,ts}": [
"eslint --fix"
],
"packages/*/index.{js,ts}": [
"packages/*/index.ts": [
"node ./scripts/generate-readmes.mts",
"git add ./packages/*/README.md"
],
Expand Down Expand Up @@ -55,9 +63,10 @@
"lint-staged": "^15.5.1",
"load-json-file": "^7.0.1",
"meow": "^13.2.0",
"nx": "^22.7.1",
"prettier": "^3.5.3",
"progress": "^2.0.3",
"tsup": "^8.4.0",
"tsx": "^4.19.4",
"typescript": "^5.8.3",
"typescript-eslint": "^8.38.0",
"yaml": "^2.8.2"
Expand Down
Loading
Loading