Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
packages:
- "packages/*"
- "test/*"

catalog:
"@types/benchmark": ^2.1.5
Expand Down
7 changes: 7 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Consumer test harnesses

Each directory is an example configuration that we may expect a Turf consumer to depend on. It allows us to test various configurations in CI and avoid shipping breaking changes unintentionally across a variety of different user groups.

Note that the CI runs include a matrix of Node versions, so each of these scenarios is tested across those as well.

The TypeScript settings were inspired by the [Choosing Compiler Options](https://www.typescriptlang.org/docs/handbook/modules/guides/choosing-compiler-options.html) documentation on the recommended configurations in May 2026.
17 changes: 17 additions & 0 deletions test/node-cjs/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-require-imports */

const turf = require("@turf/turf");

const polygon = turf.polygon([
[
[125, -15],
[113, -22],
[154, -27],
[144, -15],
[125, -15],
],
]);

const area = turf.area(polygon);

console.log(area);
14 changes: 14 additions & 0 deletions test/node-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "node-cjs",
"version": "1.0.0",
"private": true,
"license": "MIT",
"funding": "https://opencollective.com/turf",
"scripts": {
"test": "pnpm run /test:.*/",
"test:node": "node index.cjs"
},
"dependencies": {
"@turf/turf": "workspace:*"
}
}
15 changes: 15 additions & 0 deletions test/node-esm/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as turf from "@turf/turf";

const polygon = turf.polygon([
[
[125, -15],
[113, -22],
[154, -27],
[144, -15],
[125, -15],
],
]);

const area = turf.area(polygon);

console.log(area);
15 changes: 15 additions & 0 deletions test/node-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "node-esm",
"version": "1.0.0",
"private": true,
"license": "MIT",
"funding": "https://opencollective.com/turf",
"keywords": [],
"scripts": {
"test": "pnpm run /test:.*/",
"test:node": "node index.mjs"
},
"dependencies": {
"@turf/turf": "workspace:*"
}
}
18 changes: 18 additions & 0 deletions test/ts-bundler-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "ts-bundler-cjs",
"version": "1.0.0",
"private": true,
"license": "MIT",
"funding": "https://opencollective.com/turf",
"keywords": [],
"scripts": {
"test": "pnpm run /test:.*/",
"test:ts": "tsc"
},
"devDependencies": {
"typescript": "catalog:"
},
"dependencies": {
"@turf/turf": "workspace:*"
}
}
16 changes: 16 additions & 0 deletions test/ts-bundler-cjs/ts-bundler-cjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable-next-line @typescript-eslint/no-require-imports */
const turf = require("@turf/turf");

const polygon = turf.polygon([
[
[125, -15],
[113, -22],
[154, -27],
[144, -15],
[125, -15],
],
]);

const area = turf.area(polygon);

console.log(area);
12 changes: 12 additions & 0 deletions test/ts-bundler-cjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"include": ["ts-bundler-cjs.ts"],
"compilerOptions": {
"noEmit": true,
"module": "esnext",
"moduleResolution": "bundler",
"esModuleInterop": false,
"verbatimModuleSyntax": true,
"strict": true,
"skipLibCheck": false
}
}
19 changes: 19 additions & 0 deletions test/ts-bundler-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "ts-bundler-esm",
"version": "1.0.0",
"private": true,
"license": "MIT",
"funding": "https://opencollective.com/turf",
"keywords": [],
"type": "module",
"scripts": {
"test": "pnpm run /test:.*/",
"test:ts": "tsc"
},
"devDependencies": {
"typescript": "catalog:"
},
"dependencies": {
"@turf/turf": "workspace:*"
}
}
15 changes: 15 additions & 0 deletions test/ts-bundler-esm/ts-bundler-esm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as turf from "@turf/turf";

const polygon = turf.polygon([
[
[125, -15],
[113, -22],
[154, -27],
[144, -15],
[125, -15],
],
]);

const area = turf.area(polygon);

console.log(area);
12 changes: 12 additions & 0 deletions test/ts-bundler-esm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"include": ["ts-bundler-esm.ts"],
"compilerOptions": {
"noEmit": true,
"module": "esnext",
"moduleResolution": "bundler",
"esModuleInterop": false,
"verbatimModuleSyntax": true,
"strict": true,
"skipLibCheck": false
}
}
18 changes: 18 additions & 0 deletions test/ts-node-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "ts-node-cjs",
"version": "1.0.0",
"private": true,
"license": "MIT",
"funding": "https://opencollective.com/turf",
"keywords": [],
"scripts": {
"test": "pnpm run /test:.*/",
"test:ts": "tsc"
},
"devDependencies": {
"typescript": "catalog:"
},
"dependencies": {
"@turf/turf": "workspace:*"
}
}
16 changes: 16 additions & 0 deletions test/ts-node-cjs/ts-node-cjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable-next-line @typescript-eslint/no-require-imports */
const turf = require("@turf/turf");

const polygon = turf.polygon([
[
[125, -15],
[113, -22],
[154, -27],
[144, -15],
[125, -15],
],
]);

const area = turf.area(polygon);

console.log(area);
11 changes: 11 additions & 0 deletions test/ts-node-cjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"include": ["ts-node-cjs.ts"],
"compilerOptions": {
"noEmit": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"verbatimModuleSyntax": true,
"strict": true,
"skipLibCheck": false
}
}
19 changes: 19 additions & 0 deletions test/ts-node-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "ts-node-esm",
"version": "1.0.0",
"private": true,
"license": "MIT",
"funding": "https://opencollective.com/turf",
"keywords": [],
"type": "module",
"scripts": {
"test": "pnpm run /test:.*/",
"test:ts": "tsc"
},
"devDependencies": {
"typescript": "catalog:"
},
"dependencies": {
"@turf/turf": "workspace:*"
}
}
15 changes: 15 additions & 0 deletions test/ts-node-esm/ts-node-esm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as turf from "@turf/turf";

const polygon = turf.polygon([
[
[125, -15],
[113, -22],
[154, -27],
[144, -15],
[125, -15],
],
]);

const area = turf.area(polygon);

console.log(area);
11 changes: 11 additions & 0 deletions test/ts-node-esm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"include": ["ts-node-esm.ts"],
"compilerOptions": {
"noEmit": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"verbatimModuleSyntax": true,
"strict": true,
"skipLibCheck": false
}
}
Loading