Skip to content

Commit

Permalink
Add turf (#351)
Browse files Browse the repository at this point in the history
Co-authored-by: Kjetil Sletten <[email protected]>
  • Loading branch information
kjesle and Kjetil Sletten authored Oct 21, 2024
1 parent 6c6359a commit ca8f729
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"packages/lit-html",
"packages/podium-browser",
"packages/lit-labs-ssr-client",
"packages/turf",
"packages/maplibre-gl"
],
"devDependencies": {
Expand Down
42 changes: 42 additions & 0 deletions packages/turf/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { build } from "../../esbuild.js";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { createRequire } from "module";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const require = createRequire(import.meta.url);

const turfPackageJsonPath = path.join(
path.dirname(require.resolve("@turf/turf/package.json")),
"package.json"
);
const turfPackageJson = JSON.parse(fs.readFileSync(turfPackageJsonPath, "utf8"));

const turfDependencies = Object.keys(turfPackageJson.dependencies).filter((dep) =>
dep.startsWith("@turf/")
);

turfDependencies.push("@turf/turf");

await Promise.all(
turfDependencies.map((submodule) => {
const entryPoint = path.join(
__dirname,
"../../node_modules",
submodule,
"dist",
"esm",
"index.js"
);

const outfile = path.join("dist", `${submodule.replace("@turf/", "")}.min.js`);

return build({
entryPoints: [entryPoint],
outfile,
});
})
);
26 changes: 26 additions & 0 deletions packages/turf/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "turf",
"version": "0.0.0",
"description": "An ESM version of Turf-packages for Finn",
"type": "module",
"scripts": {
"copy": "echo 'noop';",
"build": "node ./esbuild.js",
"eik:login": "eik login",
"eik:publish": "eik publish",
"eik:alias": "eik npm-alias",
"eik:publish:ci": "../../scripts/publish.js turf @turf/turf"
},
"dependencies": {
"@turf/turf": "7.1.0"
},
"devDependencies": {
"esbuild": "0.24.0"
},
"eik": {
"name": "turf",
"server": "https://assets.finn.no",
"type": "npm",
"files": "dist"
}
}

0 comments on commit ca8f729

Please sign in to comment.