Skip to content

Commit 9d45647

Browse files
committed
Use tsup to build.
This also updates ts to 4.7, since this is the minimum required version for the correct node resolution.
1 parent 5135e61 commit 9d45647

File tree

119 files changed

+2377
-937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2377
-937
lines changed

.monorepolint.config.ts

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
const path = require("path");
2-
const glob = require("glob");
3-
const fs = require("fs");
1+
import path from "path";
2+
import glob from "glob";
3+
import fs from "fs";
44

5-
const TS_PACKAGES = []; // projects that use typescript to build
6-
const JS_PACKAGES = []; // projects that use javascript/rollup to build
5+
const TS_PACKAGES = [] as string[]; // projects that use typescript to build
6+
const JS_PACKAGES = [] as string[]; // projects that use javascript/rollup to build
77
const MAIN_PACKAGE = "@turf/turf";
88

9-
const TAPE_PACKAGES = []; // projects that have tape tests
10-
const TYPES_PACKAGES = []; // projects that have types tests
11-
const BENCH_PACKAGES = []; // projects that have benchmarks
9+
const TAPE_PACKAGES = [] as string[]; // projects that have tape tests
10+
const TYPES_PACKAGES = [] as string[]; // projects that have types tests
11+
const BENCH_PACKAGES = [] as string[]; // projects that have benchmarks
1212

1313
// iterate all the packages and figure out what buckets everything falls into
14-
glob.sync(path.join(__dirname, "packages", "turf-*")).forEach((pk) => {
14+
glob.sync(path.join(__dirname, "packages", "turf-*")).forEach((pk: string) => {
1515
const name = JSON.parse(
1616
fs.readFileSync(path.join(pk, "package.json"), "utf8")
17-
).name;
17+
).name as string;
1818

1919
if (fs.existsSync(path.join(pk, "index.ts"))) {
2020
TS_PACKAGES.push(name);
@@ -107,41 +107,31 @@ module.exports = {
107107
{
108108
options: {
109109
entries: {
110-
main: "dist/js/index.js",
111-
module: "dist/es/index.js",
110+
type: "commonjs",
111+
main: "dist/cjs/index.js",
112+
module: "dist/esm/index.mjs",
113+
types: "dist/cjs/index.d.ts",
112114
sideEffects: false,
113115
publishConfig: {
114116
access: "public",
115117
},
116118
exports: {
117119
"./package.json": "./package.json",
118120
".": {
119-
import: "./dist/es/index.js",
120-
require: "./dist/js/index.js",
121+
import: {
122+
types: "./dist/esm/index.d.mts",
123+
default: "./dist/esm/index.mjs",
124+
},
125+
require: {
126+
types: "./dist/cjs/index.d.ts",
127+
default: "./dist/cjs/index.js",
128+
},
121129
},
122130
},
123131
},
124132
},
125133
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
126134
},
127-
{
128-
options: {
129-
entries: {
130-
types: "dist/js/index.d.ts",
131-
files: ["dist"],
132-
},
133-
},
134-
includePackages: TS_PACKAGES,
135-
},
136-
{
137-
options: {
138-
entries: {
139-
types: "index.d.ts",
140-
files: ["dist", "index.d.ts"],
141-
},
142-
},
143-
includePackages: JS_PACKAGES,
144-
},
145135
{
146136
options: {
147137
entries: {
@@ -164,22 +154,10 @@ module.exports = {
164154
{
165155
options: {
166156
scripts: {
167-
build: "npm-run-all build:*",
168-
"build:js": "tsc",
169-
"build:es":
170-
'tsc --outDir dist/es --module esnext --declaration false && echo \'{"type":"module"}\' > dist/es/package.json',
171-
},
172-
},
173-
includePackages: TS_PACKAGES,
174-
},
175-
{
176-
options: {
177-
scripts: {
178-
build:
179-
'rollup -c ../../rollup.config.js && echo \'{"type":"module"}\' > dist/es/package.json',
157+
build: "tsup --config ../../tsup.config.ts",
180158
},
181159
},
182-
includePackages: JS_PACKAGES,
160+
includePackages: [...JS_PACKAGES, ...TS_PACKAGES],
183161
},
184162
{
185163
options: {
@@ -257,10 +235,10 @@ module.exports = {
257235
{
258236
options: {
259237
devDependencies: {
260-
rollup: "*",
238+
tsup: "^8.0.1",
261239
},
262240
},
263-
includePackages: JS_PACKAGES,
241+
includePackages: [...JS_PACKAGES, ...TS_PACKAGES],
264242
},
265243
],
266244
},

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"progress": "*",
5959
"rollup": "^2.34.2",
6060
"tape": "*",
61-
"ts-node": "^9.0.0",
62-
"typescript": "^3.8.3",
61+
"ts-node": "^10.9.0",
62+
"typescript": "~4.7.2",
6363
"yamljs": "*"
6464
}
6565
}

packages/turf-along/package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@
2323
"turf",
2424
"distance"
2525
],
26-
"main": "dist/js/index.js",
27-
"module": "dist/es/index.js",
28-
"types": "dist/js/index.d.ts",
26+
"type": "commonjs",
27+
"main": "dist/cjs/index.js",
28+
"module": "dist/esm/index.mjs",
29+
"types": "dist/cjs/index.d.ts",
2930
"exports": {
3031
"./package.json": "./package.json",
3132
".": {
32-
"import": "./dist/es/index.js",
33-
"require": "./dist/js/index.js"
33+
"import": {
34+
"types": "./dist/esm/index.d.mts",
35+
"default": "./dist/esm/index.mjs"
36+
},
37+
"require": {
38+
"types": "./dist/cjs/index.d.ts",
39+
"default": "./dist/cjs/index.js"
40+
}
3441
}
3542
},
3643
"sideEffects": false,
@@ -39,9 +46,7 @@
3946
],
4047
"scripts": {
4148
"bench": "ts-node bench.js",
42-
"build": "npm-run-all build:*",
43-
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
44-
"build:js": "tsc",
49+
"build": "tsup --config ../../tsup.config.ts",
4550
"docs": "node ../../scripts/generate-readmes",
4651
"test": "npm-run-all test:*",
4752
"test:tape": "ts-node -r esm test.js"
@@ -54,6 +59,7 @@
5459
"tape": "*",
5560
"ts-node": "*",
5661
"tslint": "*",
62+
"tsup": "^8.0.1",
5763
"typescript": "*"
5864
},
5965
"dependencies": {

packages/turf-angle/package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@
2323
"turf",
2424
"angle"
2525
],
26-
"main": "dist/js/index.js",
27-
"module": "dist/es/index.js",
28-
"types": "dist/js/index.d.ts",
26+
"type": "commonjs",
27+
"main": "dist/cjs/index.js",
28+
"module": "dist/esm/index.mjs",
29+
"types": "dist/cjs/index.d.ts",
2930
"exports": {
3031
"./package.json": "./package.json",
3132
".": {
32-
"import": "./dist/es/index.js",
33-
"require": "./dist/js/index.js"
33+
"import": {
34+
"types": "./dist/esm/index.d.mts",
35+
"default": "./dist/esm/index.mjs"
36+
},
37+
"require": {
38+
"types": "./dist/cjs/index.d.ts",
39+
"default": "./dist/cjs/index.js"
40+
}
3441
}
3542
},
3643
"sideEffects": false,
@@ -39,9 +46,7 @@
3946
],
4047
"scripts": {
4148
"bench": "ts-node bench.js",
42-
"build": "npm-run-all build:*",
43-
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
44-
"build:js": "tsc",
49+
"build": "tsup --config ../../tsup.config.ts",
4550
"docs": "node ../../scripts/generate-readmes",
4651
"test": "npm-run-all test:*",
4752
"test:tape": "ts-node -r esm test.js"
@@ -58,6 +63,7 @@
5863
"tape": "*",
5964
"ts-node": "*",
6065
"tslint": "*",
66+
"tsup": "^8.0.1",
6167
"typescript": "*",
6268
"write-json-file": "*"
6369
},

packages/turf-area/package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@
2222
"polygon",
2323
"multipolygon"
2424
],
25-
"main": "dist/js/index.js",
26-
"module": "dist/es/index.js",
27-
"types": "dist/js/index.d.ts",
25+
"type": "commonjs",
26+
"main": "dist/cjs/index.js",
27+
"module": "dist/esm/index.mjs",
28+
"types": "dist/cjs/index.d.ts",
2829
"exports": {
2930
"./package.json": "./package.json",
3031
".": {
31-
"import": "./dist/es/index.js",
32-
"require": "./dist/js/index.js"
32+
"import": {
33+
"types": "./dist/esm/index.d.mts",
34+
"default": "./dist/esm/index.mjs"
35+
},
36+
"require": {
37+
"types": "./dist/cjs/index.d.ts",
38+
"default": "./dist/cjs/index.js"
39+
}
3340
}
3441
},
3542
"sideEffects": false,
@@ -38,9 +45,7 @@
3845
],
3946
"scripts": {
4047
"bench": "ts-node bench.js",
41-
"build": "npm-run-all build:*",
42-
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
43-
"build:js": "tsc",
48+
"build": "tsup --config ../../tsup.config.ts",
4449
"docs": "node ../../scripts/generate-readmes",
4550
"test": "npm-run-all test:*",
4651
"test:tape": "ts-node -r esm test.js"
@@ -53,6 +58,7 @@
5358
"tape": "*",
5459
"ts-node": "*",
5560
"tslint": "*",
61+
"tsup": "^8.0.1",
5662
"typescript": "*",
5763
"write-json-file": "*"
5864
},

packages/turf-bbox-clip/package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@
2828
"bbox",
2929
"clip"
3030
],
31-
"main": "dist/js/index.js",
32-
"module": "dist/es/index.js",
33-
"types": "dist/js/index.d.ts",
31+
"type": "commonjs",
32+
"main": "dist/cjs/index.js",
33+
"module": "dist/esm/index.mjs",
34+
"types": "dist/cjs/index.d.ts",
3435
"exports": {
3536
"./package.json": "./package.json",
3637
".": {
37-
"import": "./dist/es/index.js",
38-
"require": "./dist/js/index.js"
38+
"import": {
39+
"types": "./dist/esm/index.d.mts",
40+
"default": "./dist/esm/index.mjs"
41+
},
42+
"require": {
43+
"types": "./dist/cjs/index.d.ts",
44+
"default": "./dist/cjs/index.js"
45+
}
3946
}
4047
},
4148
"sideEffects": false,
@@ -44,9 +51,7 @@
4451
],
4552
"scripts": {
4653
"bench": "ts-node bench.js",
47-
"build": "npm-run-all build:*",
48-
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
49-
"build:js": "tsc",
54+
"build": "tsup --config ../../tsup.config.ts",
5055
"docs": "node ../../scripts/generate-readmes",
5156
"test": "npm-run-all test:*",
5257
"test:tape": "ts-node -r esm test.js"
@@ -60,6 +65,7 @@
6065
"tape": "*",
6166
"ts-node": "*",
6267
"tslint": "*",
68+
"tsup": "^8.0.1",
6369
"typescript": "*",
6470
"write-json-file": "*"
6571
},

packages/turf-bbox-polygon/package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@
2323
"extent",
2424
"bbox"
2525
],
26-
"main": "dist/js/index.js",
27-
"module": "dist/es/index.js",
28-
"types": "dist/js/index.d.ts",
26+
"type": "commonjs",
27+
"main": "dist/cjs/index.js",
28+
"module": "dist/esm/index.mjs",
29+
"types": "dist/cjs/index.d.ts",
2930
"exports": {
3031
"./package.json": "./package.json",
3132
".": {
32-
"import": "./dist/es/index.js",
33-
"require": "./dist/js/index.js"
33+
"import": {
34+
"types": "./dist/esm/index.d.mts",
35+
"default": "./dist/esm/index.mjs"
36+
},
37+
"require": {
38+
"types": "./dist/cjs/index.d.ts",
39+
"default": "./dist/cjs/index.js"
40+
}
3441
}
3542
},
3643
"sideEffects": false,
@@ -39,9 +46,7 @@
3946
],
4047
"scripts": {
4148
"bench": "ts-node bench.js",
42-
"build": "npm-run-all build:*",
43-
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
44-
"build:js": "tsc",
49+
"build": "tsup --config ../../tsup.config.ts",
4550
"docs": "node ../../scripts/generate-readmes",
4651
"test": "npm-run-all test:*",
4752
"test:tape": "ts-node -r esm test.js"
@@ -53,6 +58,7 @@
5358
"tape": "*",
5459
"ts-node": "*",
5560
"tslint": "*",
61+
"tsup": "^8.0.1",
5662
"typescript": "*"
5763
},
5864
"dependencies": {

0 commit comments

Comments
 (0)