From f172f0b5c7183046ff93e73f99018d96b7ef7bc6 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 18 Jul 2024 00:15:12 +0200 Subject: [PATCH] package: build system --- .gitignore | 1 + index.ts | 3 +++ package.json | 5 +++++ s2/_index.ts | 3 +++ tsconfig.json | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 index.ts create mode 100644 s2/_index.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index d5f19d8..16acd49 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules +dist package-lock.json diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..74da66f --- /dev/null +++ b/index.ts @@ -0,0 +1,3 @@ +import s2 from './s2/_index' + +export default { s2 } diff --git a/package.json b/package.json index 2411856..f6d9248 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,11 @@ { "name": "s2", "version": "1.0.0", + "main": "dist/index.js", + "typings": "dist/index.d.ts", + "module": "dist/s2.esm.js", "scripts": { + "build": "tsdx build --entry index.ts", "test": "node --import tsx --test **/*_test.ts" }, "author": "Peter Johnson", @@ -9,6 +13,7 @@ "description": "javascript port of s2 geometry", "devDependencies": { "@types/node": "^20.14.11", + "tsdx": "^0.14.1", "tsx": "^4.16.2" } } diff --git a/s2/_index.ts b/s2/_index.ts new file mode 100644 index 0000000..4a1ef76 --- /dev/null +++ b/s2/_index.ts @@ -0,0 +1,3 @@ +import * as cellid from './cellid' + +export default { cellid } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..95a7567 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,32 @@ +{ + "exclude": ["**/*_test.ts"], + "compilerOptions": { + "module": "esnext", + "lib": ["dom", "esnext"], + "importHelpers": true, + // output .d.ts declaration files for consumers + "declaration": true, + // output .js.map sourcemap files for consumers + "sourceMap": true, + // match output dir to input dir. e.g. dist/index instead of dist/src/index + "rootDir": ".", + // stricter type-checking for stronger correctness. Recommended by TS + "strict": true, + // linter checks for common issues + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative + "noUnusedLocals": true, + "noUnusedParameters": true, + // use Node's module resolution algorithm, instead of the legacy TS one + "moduleResolution": "node", + // interop between ESM and CJS modules. Recommended by TS + "esModuleInterop": true, + // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS + "skipLibCheck": true, + // error out if import and file system have a casing mismatch. Recommended by TS + "forceConsistentCasingInFileNames": true, + // `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc` + "noEmit": true + } +}