From ed55a852ebc540043465dee542a4f8a0f87d9222 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:55:24 -0500 Subject: [PATCH] chore(all): fix bundling One must have dual types for dual packages. --- packages/create-sheriff-config/package.json | 6 +++++- packages/create-sheriff-config/tsconfig.json | 2 +- packages/eslint-config-sheriff/package.json | 13 ++++++++----- packages/sheriff-constants/package.json | 20 +++++++++++++++----- packages/sheriff-types/package.json | 18 ++++++++++-------- packages/sheriff-types/tsup.config.json | 8 ++++++++ packages/sheriff-utils/package.json | 9 +++------ pnpm-lock.yaml | 3 +++ 8 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 packages/sheriff-types/tsup.config.json diff --git a/packages/create-sheriff-config/package.json b/packages/create-sheriff-config/package.json index b316bc49..d99a2dbc 100644 --- a/packages/create-sheriff-config/package.json +++ b/packages/create-sheriff-config/package.json @@ -3,7 +3,11 @@ "version": "5.2.0", "type": "module", "description": "CLI/starter to bootstrap a Sheriff config", - "main": "dist/index.js", + "exports": { + ".": { + "node": "./dist/index.js" + } + }, "scripts": { "dev": "tsx ./src/index.ts", "clean": "rm -rf .turbo dist", diff --git a/packages/create-sheriff-config/tsconfig.json b/packages/create-sheriff-config/tsconfig.json index 91e2530b..ee5fe11a 100644 --- a/packages/create-sheriff-config/tsconfig.json +++ b/packages/create-sheriff-config/tsconfig.json @@ -5,7 +5,7 @@ "extends": "tsconfig/base.json", "compilerOptions": { "module": "ESNext", - "moduleResolution": "node", + "moduleResolution": "Bundler", "incremental": true, "tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json" } diff --git a/packages/eslint-config-sheriff/package.json b/packages/eslint-config-sheriff/package.json index 38483e53..39d93f8e 100644 --- a/packages/eslint-config-sheriff/package.json +++ b/packages/eslint-config-sheriff/package.json @@ -2,15 +2,18 @@ "name": "eslint-config-sheriff", "version": "18.7.0", "description": "A comprehensive and opinionated Typescript-first ESLint configuration.", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "type": "module", "exports": { "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", - "import": "./dist/index.js" + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } } }, "files": [ diff --git a/packages/sheriff-constants/package.json b/packages/sheriff-constants/package.json index a1d8f523..68c422e0 100644 --- a/packages/sheriff-constants/package.json +++ b/packages/sheriff-constants/package.json @@ -4,13 +4,19 @@ "version": "0.0.1", "private": true, "type": "module", - "main": "./dist/index.js", + "main": "./dist/index.cjs", + "module": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { - "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", - "import": "./dist/index.js" + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } } }, "files": [ @@ -18,8 +24,9 @@ "CHANGELOG.md" ], "scripts": { - "publint": "publint", "clean": "rm -rf .turb dist", + "typecheck": "tsc --noEmit", + "publint": "publint", "build": "tsup" }, "devDependencies": { @@ -28,5 +35,8 @@ "tsconfig": "workspace:*", "tsup": "^8.1.0", "typescript": "^5.5.3" + }, + "engines": { + "node": ">=16" } } diff --git a/packages/sheriff-types/package.json b/packages/sheriff-types/package.json index 7c267229..1e4e6a41 100644 --- a/packages/sheriff-types/package.json +++ b/packages/sheriff-types/package.json @@ -5,27 +5,29 @@ "license": "MIT", "type": "module", "files": [ - "src" + "dist" ], - "main": "./src/index.ts", - "types": "./src/index.ts", - "module": "./src/index.ts", "exports": { ".": { - "types": "./src/index.ts", - "import": "./src/index.ts", - "require": "./src/index.ts" + "import": { + "types": "./dist/index.d.ts" + }, + "require": { + "types": "./dist/index.d.cts" + } } }, "scripts": { "clean": "rm -rf .turbo dist", "typecheck": "tsc --noEmit", - "publint": "publint" + "publint": "publint", + "build": "tsup" }, "devDependencies": { "@types/node": "^20.14.10", "publint": "^0.2.8", "tsconfig": "workspace:*", + "tsup": "^8.1.0", "type-fest": "^4.21.0", "typescript": "^5.5.3" }, diff --git a/packages/sheriff-types/tsup.config.json b/packages/sheriff-types/tsup.config.json new file mode 100644 index 00000000..554c0ba0 --- /dev/null +++ b/packages/sheriff-types/tsup.config.json @@ -0,0 +1,8 @@ +{ + "entry": ["./src/index.ts"], + "format": ["esm", "cjs"], + "dts": true, + "splitting": false, + "sourcemap": false, + "clean": true +} diff --git a/packages/sheriff-utils/package.json b/packages/sheriff-utils/package.json index 25f89fbe..4d05f60f 100644 --- a/packages/sheriff-utils/package.json +++ b/packages/sheriff-utils/package.json @@ -7,21 +7,18 @@ "files": [ "src" ], - "main": "./src/index.ts", - "types": "./src/index.ts", - "module": "./src/index.ts", "exports": { ".": { "types": "./src/index.ts", - "import": "./src/index.ts", - "require": "./src/index.ts" + "import": "./src/index.ts" } }, "scripts": { "start": "tsx watch ./src/generateRulesDataset.ts", "rulesgen": "tsx ./src/generateRulesDataset.ts", "publint": "publint", - "clean": "rm -rf .turb dist" + "clean": "rm -rf .turb dist", + "typecheck": "tsc --noEmit" }, "devDependencies": { "@sherifforg/types": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aa7e0290..e2880664 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -525,6 +525,9 @@ importers: tsconfig: specifier: workspace:* version: link:../tsconfig + tsup: + specifier: ^8.1.0 + version: 8.1.0(typescript@5.5.3) type-fest: specifier: ^4.21.0 version: 4.21.0