Skip to content

Commit

Permalink
Fix @turf/turf
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinVdBroeck committed May 2, 2024
1 parent 9d45647 commit 44a9ee6
Show file tree
Hide file tree
Showing 9 changed files with 2,172 additions and 96 deletions.
11 changes: 2 additions & 9 deletions .monorepolint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ module.exports = {
// 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"],
exports: {
"./package.json": "./package.json",
".": {
import: "./dist/es/index.js",
require: "./dist/js/index.js",
},
},
},
},
includePackages: [MAIN_PACKAGE],
Expand Down Expand Up @@ -130,7 +123,7 @@ module.exports = {
},
},
},
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
includePackages: [MAIN_PACKAGE, ...TS_PACKAGES, ...JS_PACKAGES],
},
{
options: {
Expand Down Expand Up @@ -163,7 +156,7 @@ module.exports = {
options: {
scripts: {
build:
'rollup -c rollup.config.js && echo \'{"type":"module"}\' > dist/es/package.json',
"tsup --config ../../tsup.config.ts && rollup -c ./rollup.config.js",
},
},
includePackages: [MAIN_PACKAGE],
Expand Down
10 changes: 10 additions & 0 deletions packages/turf/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": "> 0.25%, last 2 versions, fully supports es5, not dead"
}
]
]
}
File renamed without changes.
40 changes: 27 additions & 13 deletions packages/turf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,22 @@
"jenks",
"sample"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"types": "index.d.ts",
"type": "commonjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.mjs",
"types": "dist/cjs/index.d.ts",
"browser": "turf.min.js",
"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 @@ -61,22 +68,29 @@
"turf.min.js"
],
"scripts": {
"build": "rollup -c rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build": "tsup --config ../../tsup.config.ts && rollup -c ./rollup.config.js",
"last-checks": "npm-run-all last-checks:testjs last-checks:example",
"last-checks:example": "node test.example.js",
"last-checks:testjs": "node test.js",
"test": "echo '@turf/turf tests run in the last-checks step'"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"camelcase": "*",
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@types/tape": "^4.2.32",
"camelcase": "^8.0.0",
"documentation": "^13.2.5",
"glob": "*",
"rollup": "^2.34.2",
"glob": "^10.3.10",
"rollup": "^2.79.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"rollup-plugin-terser": "^7.0.2",
"tape": "*",
"tsup": "^8.0.1"
"tape": "^5.7.2",
"tsup": "^8.0.1",
"typescript": "^5.2.2"
},
"dependencies": {
"@turf/along": "^6.5.0",
Expand Down
18 changes: 12 additions & 6 deletions packages/turf/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import node from "@rollup/plugin-node-resolve";
import nodeResolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import { terser } from "rollup-plugin-terser";
import base from "../../rollup.config";
import terser from "@rollup/plugin-terser";
import { babel } from "@rollup/plugin-babel";
import nodePolyfills from "rollup-plugin-polyfill-node";

const pckg = require("./package.json");
const input = "index.mjs";
const input = "index.ts";

export default [
{ ...base, input },
{
input,
output: [{ file: pckg.browser, format: "umd", name: "turf" }],
plugins: [commonjs(), node(), terser()],
plugins: [
commonjs(),
nodeResolve(),
nodePolyfills(),
babel({ babelHelpers: "bundled" }),
terser(),
],
},
];
2 changes: 1 addition & 1 deletion packages/turf/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const glob = require("glob");
const test = require("tape");
const camelcase = require("camelcase");
const documentation = require("documentation");
const turf = require("./dist/js/index.js");
const turf = require("./dist/cjs/index.js");

// Helpers
const directory = path.join(__dirname, "..");
Expand Down
3 changes: 3 additions & 0 deletions packages/turf/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.shared.json"
}
10 changes: 0 additions & 10 deletions rollup.config.js

This file was deleted.

Loading

0 comments on commit 44a9ee6

Please sign in to comment.