From 2990ab5e0e02c710ad9661360a4028d41d333759 Mon Sep 17 00:00:00 2001 From: jay-bulk Date: Thu, 8 Feb 2024 08:23:54 -0700 Subject: [PATCH] fix: dual export support --- package-lock.json | 49 +++++++++++++++++++++++++++--- package.json | 2 +- packages/fastify/package.json | 46 +++++++++++++++------------- packages/fastify/tsconfig.cjs.json | 5 +-- packages/fastify/tsconfig.json | 4 +-- packages/jwt/package.json | 46 +++++++++++++++------------- packages/jwt/tsconfig.cjs.json | 5 +-- packages/jwt/tsconfig.json | 6 ++-- tsconfig.cjs.json | 12 ++++++-- tsconfig.json | 7 +++-- 10 files changed, 122 insertions(+), 60 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff89279..40ebcc9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "@commitlint/cli": "^17.2.0", "@commitlint/config-angular": "^17.2.0", - "@tsconfig/esm": "^1.0.2", + "@tsconfig/node-lts": "^20.1.1", "conventional-changelog-cli": "^2.2.2", "husky": "^8.0.2", "lerna": "^7.1.1", @@ -2449,9 +2449,9 @@ "dev": true }, "node_modules/@tsconfig/node-lts": { - "version": "18.12.5", - "resolved": "https://registry.npmjs.org/@tsconfig/node-lts/-/node-lts-18.12.5.tgz", - "integrity": "sha512-KJZX0kQ5FBv77WDVzmQ9y1dUjaJCNXAAz3LSsg5cMwH0AUijVdDQtII+IVprEXdb13U9GjVOBxBzyRvr/ozPxw==", + "version": "20.1.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node-lts/-/node-lts-20.1.1.tgz", + "integrity": "sha512-V7wHydi1dv8I8xiOX3pJ0lhC+MlOakznvLks94J6y/TqQK6DBcbdD1G4jEq8yU+s6lBASPn4e1Ci636fDqeyvQ==", "dev": true }, "node_modules/@tsconfig/node10": { @@ -5195,6 +5195,18 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/echo-cli": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/echo-cli/-/echo-cli-2.0.0.tgz", + "integrity": "sha512-PHuMIwMiBaO2eNoIEu4s7631xMQCLCbP4HD3z0PIENLPiCViTSpx1MTGd8enYJCM2ldxipAOOAF0IKBSC0reNg==", + "dev": true, + "dependencies": { + "unescape-js": "^1.0.3" + }, + "bin": { + "echo-cli": "dist/index.js" + } + }, "node_modules/ejs": { "version": "3.1.9", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz", @@ -13019,6 +13031,12 @@ "node": ">=8" } }, + "node_modules/string.fromcodepoint": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/string.fromcodepoint/-/string.fromcodepoint-0.2.1.tgz", + "integrity": "sha512-n69H31OnxSGSZyZbgBlvYIXlrMhJQ0dQAX1js1QDhpaUH6zmU3QYlj07bCwCNlPOu3oRXIubGPl2gDGnHsiCqg==", + "dev": true + }, "node_modules/string.prototype.trim": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.8.tgz", @@ -13779,6 +13797,15 @@ "resolved": "https://registry.npmjs.org/uncrypto/-/uncrypto-0.1.3.tgz", "integrity": "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==" }, + "node_modules/unescape-js": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/unescape-js/-/unescape-js-1.1.4.tgz", + "integrity": "sha512-42SD8NOQEhdYntEiUQdYq/1V/YHwr1HLwlHuTJB5InVVdOSbgI6xu8jK5q65yIzuFCfczzyDF/7hbGzVbyCw0g==", + "dev": true, + "dependencies": { + "string.fromcodepoint": "^0.2.1" + } + }, "node_modules/unique-filename": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-3.0.0.tgz", @@ -14599,6 +14626,7 @@ "ava": "^5.2.0", "c8": "^7.13.0", "concurrently": "^8.2.0", + "echo-cli": "^2.0.0", "eslint": "^8.44.0", "eslint-config-standard-with-typescript": "^36.0.0", "eslint-plugin-tsdoc": "^0.2.17", @@ -14609,6 +14637,12 @@ "typescript": "^5.0.4" } }, + "packages/fastify/node_modules/@tsconfig/node-lts": { + "version": "18.12.5", + "resolved": "https://registry.npmjs.org/@tsconfig/node-lts/-/node-lts-18.12.5.tgz", + "integrity": "sha512-KJZX0kQ5FBv77WDVzmQ9y1dUjaJCNXAAz3LSsg5cMwH0AUijVdDQtII+IVprEXdb13U9GjVOBxBzyRvr/ozPxw==", + "dev": true + }, "packages/fastify/node_modules/@types/node": { "version": "18.17.15", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.15.tgz", @@ -14632,6 +14666,7 @@ "ava": "^5.2.0", "c8": "^7.13.0", "concurrently": "^8.2.0", + "echo-cli": "^2.0.0", "eslint": "^8.44.0", "eslint-config-standard-with-typescript": "^36.0.0", "eslint-plugin-tsdoc": "^0.2.17", @@ -14641,6 +14676,12 @@ "tsx": "^3.12.7", "typescript": "^5.0.4" } + }, + "packages/jwt/node_modules/@tsconfig/node-lts": { + "version": "18.12.5", + "resolved": "https://registry.npmjs.org/@tsconfig/node-lts/-/node-lts-18.12.5.tgz", + "integrity": "sha512-KJZX0kQ5FBv77WDVzmQ9y1dUjaJCNXAAz3LSsg5cMwH0AUijVdDQtII+IVprEXdb13U9GjVOBxBzyRvr/ozPxw==", + "dev": true } } } diff --git a/package.json b/package.json index 19e3e17..2601282 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "devDependencies": { "@commitlint/cli": "^17.2.0", "@commitlint/config-angular": "^17.2.0", - "@tsconfig/esm": "^1.0.2", + "@tsconfig/node-lts": "^20.1.1", "conventional-changelog-cli": "^2.2.2", "husky": "^8.0.2", "lerna": "^7.1.1", diff --git a/packages/fastify/package.json b/packages/fastify/package.json index b3d5845..43c355f 100644 --- a/packages/fastify/package.json +++ b/packages/fastify/package.json @@ -2,43 +2,46 @@ "name": "@byu-oit/fastify-jwt", "version": "0.1.7", "description": "A Fastify plugin for verifying callers JWTs with the BYU JWT package", + "homepage": "https://github.com/byu-oit/byu-jwt-nodejs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/byu-oit/byu-jwt-nodejs.git" + }, + "bugs": { + "url": "https://github.com/byu-oit/byu-jwt-nodejs/issues" + }, "keywords": [], "author": "Spencer Tuft ", "license": "Apache-2.0", "type": "module", + "types": "./dist/cjs/index.d.ts", + "main": "./dist/cjs/index.js", "exports": { + "./package.json": "./package.json", ".": { - "types": "./types/index.d.ts", - "require": "./cjs/index.js", - "import": "./esm/index.js" + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.d.ts" + }, + "require": { + "types": "./dist/cjs/index.d.ts", + "require": "./dist/cjs/index.js" + } } }, - "main": "./cjs/index.js", - "module": "./esm/index.js", - "types": "./types/index.d.ts", "files": [ - "cjs", - "esm", - "types" + "dist" ], - "repository": { - "type": "git", - "url": "git+https://github.com/byu-oit/byu-jwt-nodejs.git" - }, "scripts": { - "build": "concurrently \"npm:build:*\" -c whiteBright", - "build:cjs": "rimraf cjs && tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > cjs/package.json", - "build:esm": "rimraf esm types && tsc", - "clean": "rimraf esm cjs types", + "build": "rimraf dist && concurrently \"npm:build:*\" -c cyanBright", + "build:cjs": "tsc -p tsconfig.cjs.json && echo-cli \"{\\\"type\\\": \\\"commonjs\\\"}\" > dist/cjs/package.json", + "build:esm": "tsc -p tsconfig.json && echo-cli \"{\\\"type\\\": \\\"module\\\"}\" > dist/esm/package.json", + "clean": "rimraf dist", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "test": "ava", "test:coverage": "c8 ava" }, - "bugs": { - "url": "https://github.com/byu-oit/byu-jwt-nodejs/issues" - }, - "homepage": "https://github.com/byu-oit/byu-jwt-nodejs#readme", "dependencies": { "@byu-oit-sdk/jwt": "^0.1.0", "@byu-oit/jwt": "^0.0.7", @@ -55,6 +58,7 @@ "ava": "^5.2.0", "c8": "^7.13.0", "concurrently": "^8.2.0", + "echo-cli": "^2.0.0", "eslint": "^8.44.0", "eslint-config-standard-with-typescript": "^36.0.0", "eslint-plugin-tsdoc": "^0.2.17", diff --git a/packages/fastify/tsconfig.cjs.json b/packages/fastify/tsconfig.cjs.json index 399dd50..fd5b3dd 100644 --- a/packages/fastify/tsconfig.cjs.json +++ b/packages/fastify/tsconfig.cjs.json @@ -1,9 +1,10 @@ { "extends": "../../tsconfig.cjs.json", "compilerOptions": { - "outDir": "cjs" + "declarationDir": "dist/cjs", + "outDir": "dist/cjs" }, "include": [ "src" ] -} \ No newline at end of file +} diff --git a/packages/fastify/tsconfig.json b/packages/fastify/tsconfig.json index b5c3cc4..a7f34da 100644 --- a/packages/fastify/tsconfig.json +++ b/packages/fastify/tsconfig.json @@ -2,8 +2,8 @@ "extends": "../../tsconfig.json", "compilerOptions": { "declaration": true, - "declarationDir": "types", - "outDir": "esm", + "declarationDir": "dist/esm", + "outDir": "dist/esm", "lib": ["ES2022"] }, "include": [ diff --git a/packages/jwt/package.json b/packages/jwt/package.json index 847e05d..1972f5f 100644 --- a/packages/jwt/package.json +++ b/packages/jwt/package.json @@ -5,40 +5,43 @@ "keywords": [], "author": "Spencer Tuft ", "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/byu-oit/byu-jwt-nodejs/issues" + }, + "homepage": "https://github.com/byu-oit/byu-jwt-nodejs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/byu-oit/byu-jwt-nodejs.git" + }, "type": "module", + "types": "./dist/cjs/index.d.ts", + "main": "./dist/cjs/index.js", "exports": { + "./package.json": "./package.json", ".": { - "types": "./types/index.d.ts", - "require": "./cjs/index.js", - "import": "./esm/index.js" + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.d.ts" + }, + "require": { + "types": "./dist/cjs/index.d.ts", + "require": "./dist/cjs/index.js" + } } }, - "main": "./cjs/index.js", - "module": "./esm/index.js", - "types": "./types/index.d.ts", "files": [ - "cjs", - "esm", - "types" + "dist" ], - "repository": { - "type": "git", - "url": "git+https://github.com/byu-oit/byu-jwt-nodejs.git" - }, "scripts": { - "build": "concurrently \"npm:build:*\" -c whiteBright", - "build:cjs": "rimraf cjs && tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > cjs/package.json", - "build:esm": "rimraf esm types && tsc", - "clean": "rimraf esm cjs types", + "build": "rimraf dist && concurrently \"npm:build:*\" -c cyanBright", + "build:cjs": "tsc -p tsconfig.cjs.json && echo-cli \"{\\\"type\\\": \\\"commonjs\\\"}\" > dist/cjs/package.json", + "build:esm": "tsc -p tsconfig.json && echo-cli \"{\\\"type\\\": \\\"module\\\"}\" > dist/esm/package.json", + "clean": "rimraf dist", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "test": "ava", "test:coverage": "c8 ava" }, - "bugs": { - "url": "https://github.com/byu-oit/byu-jwt-nodejs/issues" - }, - "homepage": "https://github.com/byu-oit/byu-jwt-nodejs#readme", "dependencies": { "@byu-oit-sdk/jwt": "^0.1.0", "@sinclair/typebox": "^0.31.2", @@ -53,6 +56,7 @@ "ava": "^5.2.0", "c8": "^7.13.0", "concurrently": "^8.2.0", + "echo-cli": "^2.0.0", "eslint": "^8.44.0", "eslint-config-standard-with-typescript": "^36.0.0", "eslint-plugin-tsdoc": "^0.2.17", diff --git a/packages/jwt/tsconfig.cjs.json b/packages/jwt/tsconfig.cjs.json index 399dd50..310d119 100644 --- a/packages/jwt/tsconfig.cjs.json +++ b/packages/jwt/tsconfig.cjs.json @@ -1,9 +1,10 @@ { "extends": "../../tsconfig.cjs.json", "compilerOptions": { - "outDir": "cjs" + "declarationDir": "./dist/cjs", + "outDir": "./dist/cjs" }, "include": [ "src" ] -} \ No newline at end of file +} diff --git a/packages/jwt/tsconfig.json b/packages/jwt/tsconfig.json index fff1d15..bbd0a14 100644 --- a/packages/jwt/tsconfig.json +++ b/packages/jwt/tsconfig.json @@ -2,10 +2,10 @@ "extends": "../../tsconfig.json", "compilerOptions": { "declaration": true, - "declarationDir": "types", - "outDir": "esm" + "declarationDir": "dist/esm", + "outDir": "dist/esm" }, "include": [ "src" - ], + ] } diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 699cdac..5d7e209 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,10 +1,14 @@ { "extends": "@tsconfig/node-lts/tsconfig.json", "compilerOptions": { - "skipLibCheck": true, + "target": "es2022", + "declaration": true, + "declarationMap": true, "module": "CommonJS", + "moduleResolution": "node", "esModuleInterop": true, "importHelpers": true, + "strictNullChecks": true, "lib": [ "DOM", "ES2022" @@ -12,5 +16,9 @@ }, "include": [ "packages/*/src" + ], + "references": [ + { "path": "./packages/jwt" }, + { "path": "./packages/fastify" } ] -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index 5ee1135..5720770 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,12 @@ { - "extends": "@tsconfig/esm/tsconfig.json", "compilerOptions": { "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", + "strictNullChecks": true, "skipLibCheck": true, "esModuleInterop": true, "importHelpers": true, - "strictNullChecks": true, "lib": [ "DOM", "ES2022" @@ -15,5 +14,9 @@ }, "include": [ "packages/*/src" + ], + "references": [ + { "path": "./packages/jwt" }, + { "path": "./packages/fastify" } ] }