From f847d408080926af4f98d9cf17e192b4e5c6bd55 Mon Sep 17 00:00:00 2001 From: Alpheus <26622568+alpheustangs@users.noreply.github.com> Date: Tue, 13 Aug 2024 17:50:49 +0800 Subject: [PATCH] Fix for ESM support --- package.json | 8 ++----- packages/cli/tsconfig.json | 4 +--- packages/cli/tsup.config.ts | 13 +++++++++++ packages/rowid/package.json | 12 +++++----- packages/rowid/tsconfig.cjs.json | 3 +-- packages/rowid/tsconfig.esm.json | 3 +-- packages/rowid/tsconfig.json | 1 - packages/rowid/tsconfig.types.json | 9 -------- packages/rowid/tsup.config.ts | 25 ++++++++++++++++++++ pnpm-lock.yaml | 37 ------------------------------ tsconfig.base.json | 2 -- tsup.config.ts | 17 -------------- 12 files changed, 49 insertions(+), 85 deletions(-) create mode 100644 packages/cli/tsup.config.ts delete mode 100644 packages/rowid/tsconfig.types.json create mode 100644 packages/rowid/tsup.config.ts delete mode 100644 tsup.config.ts diff --git a/package.json b/package.json index 5268215..e259a73 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,8 @@ "scripts": { "format": "biome check --write .", "build": "npm-run-all --sequential build:id build:cli", - "build:id": "npm-run-all --parallel build:id:esm build:id:cjs build:id:types", - "build:id:esm": "cd ./packages/rowid && tsc -p tsconfig.esm.json && tsc-alias -p tsconfig.esm.json", - "build:id:cjs": "cd ./packages/rowid && tsc -p tsconfig.cjs.json && tsc-alias -p tsconfig.cjs.json", - "build:id:types": "cd ./packages/rowid && tsc -p tsconfig.types.json && tsc-alias -p tsconfig.types.json", - "build:cli": "tsup", + "build:id": "cd ./packages/rowid && tsup", + "build:cli": "cd ./packages/cli && tsup", "test": "npm-run-all --sequential test:id test:cli", "test:id": "cd ./tests/rowid && pnpm run test", "test:cli": "cd ./tests/cli && pnpm run test", @@ -18,7 +15,6 @@ "@biomejs/biome": "^1.8.3", "@types/node": "^22.2.0", "npm-run-all": "^4.1.5", - "tsc-alias": "^1.8.10", "tsup": "^8.2.4", "typescript": "^5.5.4" } diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index c1739cd..d0f9ca0 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -3,12 +3,10 @@ "compilerOptions": { "target": "ES5", "module": "CommonJS", - "rootDir": "./src", "baseUrl": ".", "paths": { "#/*": ["./src/*"] - }, - "outDir": "./dist" + } }, "include": ["./src/**/*"] } diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts new file mode 100644 index 0000000..b4c5c72 --- /dev/null +++ b/packages/cli/tsup.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from "tsup"; + +export default defineConfig([ + { + minify: true, + platform: "node", + tsconfig: "./tsconfig.json", + entry: { + index: "./src/index.ts", + }, + outDir: "./dist", + }, +]); diff --git a/packages/rowid/package.json b/packages/rowid/package.json index b39878f..4d2afbe 100644 --- a/packages/rowid/package.json +++ b/packages/rowid/package.json @@ -21,14 +21,14 @@ "license": "MIT", "author": "Alpheus Tang", "files": ["dist"], - "main": "./dist/cjs/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/types/index.d.ts", + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/cjs/index.js", - "import": "./dist/esm/index.js", - "types": "./dist/types/index.d.ts" + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" } }, "repository": { diff --git a/packages/rowid/tsconfig.cjs.json b/packages/rowid/tsconfig.cjs.json index 2d1d83d..311de8f 100644 --- a/packages/rowid/tsconfig.cjs.json +++ b/packages/rowid/tsconfig.cjs.json @@ -2,7 +2,6 @@ "extends": "./tsconfig.json", "compilerOptions": { "target": "ES5", - "module": "CommonJS", - "outDir": "./dist/cjs" + "module": "CommonJS" } } diff --git a/packages/rowid/tsconfig.esm.json b/packages/rowid/tsconfig.esm.json index 5b0f398..e1f4d07 100644 --- a/packages/rowid/tsconfig.esm.json +++ b/packages/rowid/tsconfig.esm.json @@ -2,7 +2,6 @@ "extends": "./tsconfig.json", "compilerOptions": { "target": "ES2015", - "module": "ES2015", - "outDir": "./dist/esm" + "module": "ES2015" } } diff --git a/packages/rowid/tsconfig.json b/packages/rowid/tsconfig.json index 667acc7..5f9a0ab 100644 --- a/packages/rowid/tsconfig.json +++ b/packages/rowid/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "rootDir": "./src", "baseUrl": ".", "paths": { "#/*": ["./src/*"] diff --git a/packages/rowid/tsconfig.types.json b/packages/rowid/tsconfig.types.json deleted file mode 100644 index a229700..0000000 --- a/packages/rowid/tsconfig.types.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "removeComments": false, - "outDir": "./dist/types" - } -} diff --git a/packages/rowid/tsup.config.ts b/packages/rowid/tsup.config.ts new file mode 100644 index 0000000..a5adea2 --- /dev/null +++ b/packages/rowid/tsup.config.ts @@ -0,0 +1,25 @@ +import { defineConfig } from "tsup"; + +export default defineConfig([ + { + minify: true, + platform: "neutral", + format: "esm", + tsconfig: "./tsconfig.esm.json", + entry: { + index: "./src/index.ts", + }, + outDir: "./dist", + }, + { + dts: true, + minify: true, + platform: "neutral", + format: "cjs", + tsconfig: "./tsconfig.cjs.json", + entry: { + index: "./src/index.ts", + }, + outDir: "./dist", + }, +]); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13979da..b85c7e7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,9 +17,6 @@ importers: npm-run-all: specifier: ^4.1.5 version: 4.1.5 - tsc-alias: - specifier: ^1.8.10 - version: 1.8.10 tsup: specifier: ^8.2.4 version: 8.2.4(typescript@5.5.4) @@ -1257,11 +1254,6 @@ packages: engines: {node: '>= 6'} dev: true - /commander@9.5.0: - resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} - engines: {node: ^12.20.0 || >=14} - dev: true - /concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} dev: true @@ -2125,11 +2117,6 @@ packages: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true - /mylas@2.1.13: - resolution: {integrity: sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==} - engines: {node: '>=12.0.0'} - dev: true - /mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} dependencies: @@ -2318,13 +2305,6 @@ packages: engines: {node: '>= 6'} dev: true - /plimit-lit@1.6.1: - resolution: {integrity: sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==} - engines: {node: '>=12'} - dependencies: - queue-lit: 1.5.2 - dev: true - /possible-typed-array-names@1.0.0: resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} engines: {node: '>= 0.4'} @@ -2372,11 +2352,6 @@ packages: engines: {node: '>=6'} dev: true - /queue-lit@1.5.2: - resolution: {integrity: sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==} - engines: {node: '>=12'} - dev: true - /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -2804,18 +2779,6 @@ packages: yn: 3.1.1 dev: true - /tsc-alias@1.8.10: - resolution: {integrity: sha512-Ibv4KAWfFkFdKJxnWfVtdOmB0Zi1RJVxcbPGiCDsFpCQSsmpWyuzHG3rQyI5YkobWwxFPEyQfu1hdo4qLG2zPw==} - hasBin: true - dependencies: - chokidar: 3.6.0 - commander: 9.5.0 - globby: 11.1.0 - mylas: 2.1.13 - normalize-path: 3.0.0 - plimit-lit: 1.6.1 - dev: true - /tslib@2.6.3: resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} dev: true diff --git a/tsconfig.base.json b/tsconfig.base.json index a3e1b5d..2ccd275 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -2,8 +2,6 @@ "compilerOptions": { "moduleResolution": "Node10", "resolveJsonModule": true, - "declaration": false, - "removeComments": true, "downlevelIteration": true, "isolatedModules": true, "esModuleInterop": true, diff --git a/tsup.config.ts b/tsup.config.ts deleted file mode 100644 index 1c3d161..0000000 --- a/tsup.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as path from "node:path"; - -import { defineConfig } from "tsup"; - -const pkg: string = path.resolve(process.cwd(), "packages", "cli"); - -export default defineConfig([ - { - minify: true, - platform: "node", - tsconfig: path.join(pkg, "tsconfig.json"), - entry: { - index: path.join(pkg, "src", "index.ts"), - }, - outDir: path.join(pkg, "dist"), - }, -]);