Skip to content

Commit

Permalink
Use tsup to build.
Browse files Browse the repository at this point in the history
This also updates ts to 4.7, since this is the minimum required version
for the correct node resolution.
  • Loading branch information
RobinVdBroeck committed May 2, 2024
1 parent 5135e61 commit 9d45647
Show file tree
Hide file tree
Showing 119 changed files with 2,377 additions and 937 deletions.
74 changes: 26 additions & 48 deletions .monorepolint.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const path = require("path");
const glob = require("glob");
const fs = require("fs");
import path from "path";
import glob from "glob";
import fs from "fs";

const TS_PACKAGES = []; // projects that use typescript to build
const JS_PACKAGES = []; // projects that use javascript/rollup to build
const TS_PACKAGES = [] as string[]; // projects that use typescript to build
const JS_PACKAGES = [] as string[]; // projects that use javascript/rollup to build
const MAIN_PACKAGE = "@turf/turf";

const TAPE_PACKAGES = []; // projects that have tape tests
const TYPES_PACKAGES = []; // projects that have types tests
const BENCH_PACKAGES = []; // projects that have benchmarks
const TAPE_PACKAGES = [] as string[]; // projects that have tape tests
const TYPES_PACKAGES = [] as string[]; // projects that have types tests
const BENCH_PACKAGES = [] as string[]; // projects that have benchmarks

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

if (fs.existsSync(path.join(pk, "index.ts"))) {
TS_PACKAGES.push(name);
Expand Down Expand Up @@ -107,41 +107,31 @@ module.exports = {
{
options: {
entries: {
main: "dist/js/index.js",
module: "dist/es/index.js",
type: "commonjs",
main: "dist/cjs/index.js",
module: "dist/esm/index.mjs",
types: "dist/cjs/index.d.ts",
sideEffects: false,
publishConfig: {
access: "public",
},
exports: {
"./package.json": "./package.json",
".": {
import: "./dist/es/index.js",
require: "./dist/js/index.js",
import: {
types: "./dist/esm/index.d.mts",
default: "./dist/esm/index.mjs",
},
require: {
types: "./dist/cjs/index.d.ts",
default: "./dist/cjs/index.js",
},
},
},
},
},
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
},
{
options: {
entries: {
types: "dist/js/index.d.ts",
files: ["dist"],
},
},
includePackages: TS_PACKAGES,
},
{
options: {
entries: {
types: "index.d.ts",
files: ["dist", "index.d.ts"],
},
},
includePackages: JS_PACKAGES,
},
{
options: {
entries: {
Expand All @@ -164,22 +154,10 @@ module.exports = {
{
options: {
scripts: {
build: "npm-run-all build:*",
"build:js": "tsc",
"build:es":
'tsc --outDir dist/es --module esnext --declaration false && echo \'{"type":"module"}\' > dist/es/package.json',
},
},
includePackages: TS_PACKAGES,
},
{
options: {
scripts: {
build:
'rollup -c ../../rollup.config.js && echo \'{"type":"module"}\' > dist/es/package.json',
build: "tsup --config ../../tsup.config.ts",
},
},
includePackages: JS_PACKAGES,
includePackages: [...JS_PACKAGES, ...TS_PACKAGES],
},
{
options: {
Expand Down Expand Up @@ -257,10 +235,10 @@ module.exports = {
{
options: {
devDependencies: {
rollup: "*",
tsup: "^8.0.1",
},
},
includePackages: JS_PACKAGES,
includePackages: [...JS_PACKAGES, ...TS_PACKAGES],
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"progress": "*",
"rollup": "^2.34.2",
"tape": "*",
"ts-node": "^9.0.0",
"typescript": "^3.8.3",
"ts-node": "^10.9.0",
"typescript": "~4.7.2",
"yamljs": "*"
}
}
22 changes: 14 additions & 8 deletions packages/turf-along/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@
"turf",
"distance"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"types": "dist/js/index.d.ts",
"type": "commonjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.mjs",
"types": "dist/cjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"sideEffects": false,
Expand All @@ -39,9 +46,7 @@
],
"scripts": {
"bench": "ts-node bench.js",
"build": "npm-run-all build:*",
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:js": "tsc",
"build": "tsup --config ../../tsup.config.ts",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "ts-node -r esm test.js"
Expand All @@ -54,6 +59,7 @@
"tape": "*",
"ts-node": "*",
"tslint": "*",
"tsup": "^8.0.1",
"typescript": "*"
},
"dependencies": {
Expand Down
22 changes: 14 additions & 8 deletions packages/turf-angle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@
"turf",
"angle"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"types": "dist/js/index.d.ts",
"type": "commonjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.mjs",
"types": "dist/cjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"sideEffects": false,
Expand All @@ -39,9 +46,7 @@
],
"scripts": {
"bench": "ts-node bench.js",
"build": "npm-run-all build:*",
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:js": "tsc",
"build": "tsup --config ../../tsup.config.ts",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "ts-node -r esm test.js"
Expand All @@ -58,6 +63,7 @@
"tape": "*",
"ts-node": "*",
"tslint": "*",
"tsup": "^8.0.1",
"typescript": "*",
"write-json-file": "*"
},
Expand Down
22 changes: 14 additions & 8 deletions packages/turf-area/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@
"polygon",
"multipolygon"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"types": "dist/js/index.d.ts",
"type": "commonjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.mjs",
"types": "dist/cjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"sideEffects": false,
Expand All @@ -38,9 +45,7 @@
],
"scripts": {
"bench": "ts-node bench.js",
"build": "npm-run-all build:*",
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:js": "tsc",
"build": "tsup --config ../../tsup.config.ts",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "ts-node -r esm test.js"
Expand All @@ -53,6 +58,7 @@
"tape": "*",
"ts-node": "*",
"tslint": "*",
"tsup": "^8.0.1",
"typescript": "*",
"write-json-file": "*"
},
Expand Down
22 changes: 14 additions & 8 deletions packages/turf-bbox-clip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@
"bbox",
"clip"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"types": "dist/js/index.d.ts",
"type": "commonjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.mjs",
"types": "dist/cjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"sideEffects": false,
Expand All @@ -44,9 +51,7 @@
],
"scripts": {
"bench": "ts-node bench.js",
"build": "npm-run-all build:*",
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:js": "tsc",
"build": "tsup --config ../../tsup.config.ts",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "ts-node -r esm test.js"
Expand All @@ -60,6 +65,7 @@
"tape": "*",
"ts-node": "*",
"tslint": "*",
"tsup": "^8.0.1",
"typescript": "*",
"write-json-file": "*"
},
Expand Down
22 changes: 14 additions & 8 deletions packages/turf-bbox-polygon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@
"extent",
"bbox"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"types": "dist/js/index.d.ts",
"type": "commonjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.mjs",
"types": "dist/cjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"sideEffects": false,
Expand All @@ -39,9 +46,7 @@
],
"scripts": {
"bench": "ts-node bench.js",
"build": "npm-run-all build:*",
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:js": "tsc",
"build": "tsup --config ../../tsup.config.ts",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "ts-node -r esm test.js"
Expand All @@ -53,6 +58,7 @@
"tape": "*",
"ts-node": "*",
"tslint": "*",
"tsup": "^8.0.1",
"typescript": "*"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 9d45647

Please sign in to comment.