commit 1e84ae468edc0d82e7139ae19894af28f83e8189
parent 3ced8949e2d37055bfa6e831cf9b172444481d11
Author: triesap <137732411+triesap@users.noreply.github.com>
Date: Mon, 10 Feb 2025 10:00:11 +0000
geocoder: migrate from direct index.ts entry to tsup compilation
Diffstat:
7 files changed, 59 insertions(+), 22 deletions(-)
diff --git a/geocoder/.gitignore b/geocoder/.gitignore
@@ -18,19 +18,30 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
-# local env files
-.env.local
-.env.development.local
-.env.test.local
-.env.production.local
-
# turbo
.turbo
+
+# Output
+.output
+/build
+dist
+
+# local env files
+.env*
+!.env.example
+
+
+# Vite
+vite.config.js.timestamp-*
+vite.config.ts.timestamp-*
+
+# local
.tmp*
+.backup*
+.dev*
.vscode
notes*.txt
notes*.md
-justfile
-dist
git-diff.txt
+justfile
diff --git a/geocoder/package.json b/geocoder/package.json
@@ -4,20 +4,30 @@
"private": true,
"license": "GPLv3",
"type": "module",
- "module": "index.ts",
+ "main": "dist/index.js",
+ "module": "dist/index.js",
+ "types": "dist/index.d.ts",
+ "exports": {
+ ".": {
+ "import": "./dist/index.js",
+ "require": "./dist/index.cjs"
+ }
+ },
"scripts": {
- "build": "just build && tsc",
- "dev": "tsc -w"
+ "build": "tsup",
+ "dev": "tsup --watch",
+ "watch": "tsc -w"
},
"devDependencies": {
"@types/sql.js": "^1.4.9",
+ "tsup": "^6.2.3",
"typescript": "^5.3.3"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
- "@radroots/utils": "workspace:*",
- "sql.js": "^1.11.0"
+ "@radroots/util": "workspace:*",
+ "sql.js": "1.12.0"
}
}
\ No newline at end of file
diff --git a/geocoder/src/geocoder.ts b/geocoder/src/geocoder.ts
@@ -1,4 +1,4 @@
-import { err_msg, type GeolocationCoordinatesPoint } from "@radroots/utils";
+import { err_msg, type GeolocationCoordinatesPoint } from "@radroots/util";
import type { Database } from "sql.js";
import type { GeocoderReverseResult, IGeocoder, IGeocoderConnectResolve, IGeocoderCountryCenter, IGeocoderCountryCenterResolve, IGeocoderCountryListResolve, IGeocoderCountryListResult, IGeocoderCountryResolve, IGeocoderReverseOpts, IGeocoderReverseResolve } from "./types";
import { parse_geocode_country_center_result, parse_geocode_country_list_result, parse_geocode_reverse_result } from "./utils";
diff --git a/geocoder/src/types.ts b/geocoder/src/types.ts
@@ -1,4 +1,4 @@
-import type { ErrorMessage, GeolocationCoordinatesPoint, ResultObj, ResultsList } from "@radroots/utils";
+import type { ErrorMessage, GeolocationCoordinatesPoint, ResultObj, ResultsList } from "@radroots/util";
export type GeocoderErrorMessage =
| `*-result`
diff --git a/geocoder/src/utils.ts b/geocoder/src/utils.ts
@@ -1,4 +1,4 @@
-import type { GeolocationCoordinatesPoint } from "@radroots/utils";
+import type { GeolocationCoordinatesPoint } from "@radroots/util";
import type { GeocoderReverseResult, IGeocoderCountryListResult } from "./types";
export const parse_geocode_reverse_result = (obj: any): GeocoderReverseResult | undefined => {
diff --git a/geocoder/tsconfig.json b/geocoder/tsconfig.json
@@ -1,21 +1,26 @@
{
"compilerOptions": {
"strict": true,
+ "target": "es2021",
"lib": [
"es2021",
- "WebWorker",
+ "WebWorker"
],
- "target": "es2021",
- "module": "CommonJS",
+ "module": "ESNext",
+ "moduleResolution": "node",
+ "declaration": true,
+ "declarationMap": true,
"outDir": "./dist",
- "rootDir": "./src",
- "noEmit": true,
+ "esModuleInterop": true,
"skipLibCheck": true,
+ "baseUrl": ".",
+ "rootDir": "./src",
},
"include": [
"src"
],
"exclude": [
- "node_modules"
+ "node_modules",
+ "dist"
],
}
\ No newline at end of file
diff --git a/geocoder/tsup.config.ts b/geocoder/tsup.config.ts
@@ -0,0 +1,11 @@
+import { defineConfig } from "tsup";
+
+export default defineConfig({
+ entry: ['src/index.ts'],
+ format: ['esm', 'cjs'],
+ dts: true,
+ outDir: 'dist',
+ splitting: true,
+ clean: true,
+ sourcemap: true,
+});