diff --git a/package.json b/package.json index 051b958..6703697 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "packages/lit-html", "packages/podium-browser", "packages/lit-labs-ssr-client", + "packages/turf", "packages/maplibre-gl" ], "devDependencies": { diff --git a/packages/turf/esbuild.js b/packages/turf/esbuild.js new file mode 100644 index 0000000..d80cfeb --- /dev/null +++ b/packages/turf/esbuild.js @@ -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, + }); + }) +); diff --git a/packages/turf/package.json b/packages/turf/package.json new file mode 100644 index 0000000..f968ffe --- /dev/null +++ b/packages/turf/package.json @@ -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" + } +}