From fe5c2db16052feac1d22d392d25731a52431be72 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Sun, 25 Feb 2024 16:34:51 -0500 Subject: [PATCH 1/2] feat: package is now ESM BREAKING CHANGE: package is now ESM --- .github/workflows/update.yml | 2 +- README.md | 6 +- package-lock.json | 190 ++++++------------------ package.json | 15 +- scripts/build.mjs | 40 ++--- scripts/update-endpoints/code.mjs | 13 +- scripts/update-endpoints/docs.mjs | 4 +- scripts/update-endpoints/fetch-json.mjs | 8 +- scripts/update-endpoints/types.mjs | 4 +- test/rest-endpoint-methods.test.ts | 3 +- test/tsconfig.test.json | 1 - test/typescript.test.ts | 5 +- 12 files changed, 86 insertions(+), 205 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 6ea9165fd..916f182e4 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -18,7 +18,7 @@ jobs: token: ${{ secrets.OCTOKITBOT_PAT }} - uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 20 cache: npm - run: git checkout routes-update || true - run: npm install @octokit/types@latest diff --git a/README.md b/README.md index ee4f952e3..b9f015191 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,8 @@ Node Install with `npm install @octokit/core @octokit/plugin-rest-endpoint-methods`. Optionally replace `@octokit/core` with a compatible module ```js -const { Octokit } = require("@octokit/core"); -const { - restEndpointMethods, -} = require("@octokit/plugin-rest-endpoint-methods"); +import { Octokit } from "@octokit/core"; +import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods"; ``` diff --git a/package-lock.json b/package-lock.json index cd36de829..c3ee9dc54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,8 @@ "@octokit/types": "^12.6.0" }, "devDependencies": { - "@octokit/core": "^5.0.0", - "@octokit/tsconfig": "^2.0.0", + "@octokit/core": "^6.0.0", + "@octokit/tsconfig": "^3.0.0", "@types/fetch-mock": "^7.3.1", "@types/jest": "^29.0.0", "@types/node": "^20.0.0", @@ -40,7 +40,7 @@ "node": ">= 18" }, "peerDependencies": { - "@octokit/core": ">=5" + "@octokit/core": ">=6" } }, "node_modules/@ampproject/remapping": { @@ -1506,174 +1506,96 @@ "license": "MIT" }, "node_modules/@octokit/auth-token": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", - "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-5.0.0.tgz", + "integrity": "sha512-JpQdKWTuu79A6YDaOfl9/HFvdhEwlRSTE/MFLGl8eU+XK6jIuqhxEftJNDpQjem1J7GLcs+4sapP1JXNPTDP/A==", "dev": true, "engines": { "node": ">= 18" } }, "node_modules/@octokit/core": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.0.tgz", - "integrity": "sha512-YbAtMWIrbZ9FCXbLwT9wWB8TyLjq9mxpKdgB3dUNxQcIVTf9hJ70gRPwAcqGZdY6WdJPZ0I7jLaaNDCiloGN2A==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.0.0.tgz", + "integrity": "sha512-0JifUnQKGoX83rMhy5bk2QNAPcO5hjD082YZ+wjqUa509RaZIn3F5SeqbKJoc2Zh+ld7rEQmlIeJzhVamSW2Xw==", "dev": true, "dependencies": { - "@octokit/auth-token": "^4.0.0", - "@octokit/graphql": "^7.0.0", - "@octokit/request": "^8.0.2", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^11.0.0", - "before-after-hook": "^2.2.0", - "universal-user-agent": "^6.0.0" + "@octokit/auth-token": "^5.0.0", + "@octokit/graphql": "^8.0.0", + "@octokit/request": "^9.0.0", + "@octokit/request-error": "^6.0.1", + "@octokit/types": "^12.0.0", + "before-after-hook": "^3.0.2", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, - "node_modules/@octokit/core/node_modules/@octokit/openapi-types": { - "version": "18.1.1", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-18.1.1.tgz", - "integrity": "sha512-VRaeH8nCDtF5aXWnjPuEMIYf1itK/s3JYyJcWFJT8X9pSNnBtriDf7wlEWsGuhPLl4QIH4xM8fqTXDwJ3Mu6sw==", - "dev": true - }, - "node_modules/@octokit/core/node_modules/@octokit/types": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-11.1.0.tgz", - "integrity": "sha512-Fz0+7GyLm/bHt8fwEqgvRBWwIV1S6wRRyq+V6exRKLVWaKGsuy6H9QFYeBVDV7rK6fO3XwHgQOPxv+cLj2zpXQ==", - "dev": true, - "dependencies": { - "@octokit/openapi-types": "^18.0.0" - } - }, "node_modules/@octokit/endpoint": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.0.tgz", - "integrity": "sha512-szrQhiqJ88gghWY2Htt8MqUDO6++E/EIXqJ2ZEp5ma3uGS46o7LZAzSLt49myB7rT+Hfw5Y6gO3LmOxGzHijAQ==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.0.0.tgz", + "integrity": "sha512-emBcNDxBdC1y3+knJonS5zhUB/CG6TihubxM2U1/pG/Z1y3a4oV0Gzz3lmkCvWWQI6h3tqBAX9MgCBFp+M68Jw==", "dev": true, "dependencies": { - "@octokit/types": "^11.0.0", - "is-plain-object": "^5.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/types": "^12.0.0", + "universal-user-agent": "^7.0.2" }, "engines": { "node": ">= 18" } }, - "node_modules/@octokit/endpoint/node_modules/@octokit/openapi-types": { - "version": "18.1.1", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-18.1.1.tgz", - "integrity": "sha512-VRaeH8nCDtF5aXWnjPuEMIYf1itK/s3JYyJcWFJT8X9pSNnBtriDf7wlEWsGuhPLl4QIH4xM8fqTXDwJ3Mu6sw==", - "dev": true - }, - "node_modules/@octokit/endpoint/node_modules/@octokit/types": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-11.1.0.tgz", - "integrity": "sha512-Fz0+7GyLm/bHt8fwEqgvRBWwIV1S6wRRyq+V6exRKLVWaKGsuy6H9QFYeBVDV7rK6fO3XwHgQOPxv+cLj2zpXQ==", - "dev": true, - "dependencies": { - "@octokit/openapi-types": "^18.0.0" - } - }, "node_modules/@octokit/graphql": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.1.tgz", - "integrity": "sha512-T5S3oZ1JOE58gom6MIcrgwZXzTaxRnxBso58xhozxHpOqSTgDS6YNeEUvZ/kRvXgPrRz/KHnZhtb7jUMRi9E6w==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-8.0.0.tgz", + "integrity": "sha512-9B2HwWSb12ldwrp6pC8BFTsSCeidW7do0lMgWNH65IXRVteN503JJSWPH1VEM+qP8+/Ka1pw3MTs+3Q6Bjqukw==", "dev": true, "dependencies": { - "@octokit/request": "^8.0.1", - "@octokit/types": "^11.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/request": "^9.0.0", + "@octokit/types": "^12.0.0", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, - "node_modules/@octokit/graphql/node_modules/@octokit/openapi-types": { - "version": "18.1.1", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-18.1.1.tgz", - "integrity": "sha512-VRaeH8nCDtF5aXWnjPuEMIYf1itK/s3JYyJcWFJT8X9pSNnBtriDf7wlEWsGuhPLl4QIH4xM8fqTXDwJ3Mu6sw==", - "dev": true - }, - "node_modules/@octokit/graphql/node_modules/@octokit/types": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-11.1.0.tgz", - "integrity": "sha512-Fz0+7GyLm/bHt8fwEqgvRBWwIV1S6wRRyq+V6exRKLVWaKGsuy6H9QFYeBVDV7rK6fO3XwHgQOPxv+cLj2zpXQ==", - "dev": true, - "dependencies": { - "@octokit/openapi-types": "^18.0.0" - } - }, "node_modules/@octokit/openapi-types": { "version": "20.0.0", "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-20.0.0.tgz", "integrity": "sha512-EtqRBEjp1dL/15V7WiX5LJMIxxkdiGJnabzYx5Apx4FkQIFgAfKumXeYAqqJCj1s+BMX4cPFIFC4OLCR6stlnA==" }, "node_modules/@octokit/request": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.0.4.tgz", - "integrity": "sha512-YZ1XeDRil4ejHKoBP8BgROgP4auOH5A9lLZH96l39GKKEmsKOccQxKP5M7m+Punblg1bFw8LrdeKIDwIzQ8afA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.0.0.tgz", + "integrity": "sha512-hShsrZ40W8dz3TkyD5ifHNcrYfYpYF7Sh2x+ZKafA+eO0zNeKDTsbF1E0xrUf0mVYGeKL+NLMO5SnfAP22l05Q==", "dev": true, "dependencies": { - "@octokit/endpoint": "^9.0.0", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^11.0.0", - "is-plain-object": "^5.0.0", - "universal-user-agent": "^6.0.0" + "@octokit/endpoint": "^10.0.0", + "@octokit/request-error": "^6.0.1", + "@octokit/types": "^12.0.0", + "universal-user-agent": "^7.0.2" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/request-error": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.0.tgz", - "integrity": "sha512-1ue0DH0Lif5iEqT52+Rf/hf0RmGO9NWFjrzmrkArpG9trFfDM/efx00BJHdLGuro4BR/gECxCU2Twf5OKrRFsQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.0.1.tgz", + "integrity": "sha512-EPeILOAEGqwmEG6g7dYlbvqkjJ5nWNcZvQpgeLEn1MieIcJ0xK0CJtvVcIMXqzIM8DOWzvI6zL5FQAwjTvk/Tg==", "dev": true, "dependencies": { - "@octokit/types": "^11.0.0", - "deprecation": "^2.0.0", - "once": "^1.4.0" + "@octokit/types": "^12.0.0" }, "engines": { "node": ">= 18" } }, - "node_modules/@octokit/request-error/node_modules/@octokit/openapi-types": { - "version": "18.1.1", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-18.1.1.tgz", - "integrity": "sha512-VRaeH8nCDtF5aXWnjPuEMIYf1itK/s3JYyJcWFJT8X9pSNnBtriDf7wlEWsGuhPLl4QIH4xM8fqTXDwJ3Mu6sw==", - "dev": true - }, - "node_modules/@octokit/request-error/node_modules/@octokit/types": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-11.1.0.tgz", - "integrity": "sha512-Fz0+7GyLm/bHt8fwEqgvRBWwIV1S6wRRyq+V6exRKLVWaKGsuy6H9QFYeBVDV7rK6fO3XwHgQOPxv+cLj2zpXQ==", - "dev": true, - "dependencies": { - "@octokit/openapi-types": "^18.0.0" - } - }, - "node_modules/@octokit/request/node_modules/@octokit/openapi-types": { - "version": "18.1.1", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-18.1.1.tgz", - "integrity": "sha512-VRaeH8nCDtF5aXWnjPuEMIYf1itK/s3JYyJcWFJT8X9pSNnBtriDf7wlEWsGuhPLl4QIH4xM8fqTXDwJ3Mu6sw==", - "dev": true - }, - "node_modules/@octokit/request/node_modules/@octokit/types": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-11.1.0.tgz", - "integrity": "sha512-Fz0+7GyLm/bHt8fwEqgvRBWwIV1S6wRRyq+V6exRKLVWaKGsuy6H9QFYeBVDV7rK6fO3XwHgQOPxv+cLj2zpXQ==", - "dev": true, - "dependencies": { - "@octokit/openapi-types": "^18.0.0" - } - }, "node_modules/@octokit/tsconfig": { - "version": "2.0.0", - "dev": true, - "license": "MIT" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-3.0.0.tgz", + "integrity": "sha512-tQLwgXYfBq9iUbOq26kWCzsJL6DY7qjOLzqcg5tCFQ4ob48H47iX98NudHW7S5OQ/fpSKYJhb3eQehyBNzYjfA==", + "dev": true }, "node_modules/@octokit/types": { "version": "12.6.0", @@ -2078,9 +2000,10 @@ "license": "MIT" }, "node_modules/before-after-hook": { - "version": "2.2.3", - "dev": true, - "license": "Apache-2.0" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-3.0.2.tgz", + "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==", + "dev": true }, "node_modules/brace-expansion": { "version": "2.0.1", @@ -2460,12 +2383,6 @@ "node": ">=10" } }, - "node_modules/deprecation": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", - "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", - "dev": true - }, "node_modules/detect-newline": { "version": "3.1.0", "dev": true, @@ -3107,15 +3024,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-plain-object": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", - "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-stream": { "version": "2.0.1", "dev": true, @@ -5376,9 +5284,9 @@ "dev": true }, "node_modules/universal-user-agent": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", - "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz", + "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==", "dev": true }, "node_modules/update-browserslist-db": { diff --git a/package.json b/package.json index 0a8058dc8..3f24dfc96 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "@octokit/plugin-rest-endpoint-methods", "version": "0.0.0-development", + "type": "module", "description": "Octokit plugin adding one method for all of api.github.com REST API endpoints", "scripts": { "build": "node scripts/build.mjs && tsc -p tsconfig.json", "lint": "prettier --check '{src,test,scripts}/**/*' '!scripts/update-endpoints/generated/**' '!src/generated/**' README.md package.json", "lint:fix": "prettier --write '{src,test,scripts}/**/*' '!scripts/update-endpoints/generated/**' '!src/generated/**' README.md package.json", "pretest": "npm run -s lint", - "test": "jest --coverage", + "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage", "update-endpoints": "npm-run-all update-endpoints:*", "update-endpoints:fetch-json": "node scripts/update-endpoints/fetch-json.mjs", "update-endpoints:code": "node scripts/update-endpoints/code.mjs", @@ -27,8 +28,8 @@ "@octokit/types": "^12.6.0" }, "devDependencies": { - "@octokit/core": "^5.0.0", - "@octokit/tsconfig": "^2.0.0", + "@octokit/core": "^6.0.0", + "@octokit/tsconfig": "^3.0.0", "@types/fetch-mock": "^7.3.1", "@types/jest": "^29.0.0", "@types/node": "^20.0.0", @@ -52,14 +53,18 @@ "typescript": "^5.0.0" }, "peerDependencies": { - "@octokit/core": ">=5" + "@octokit/core": ">=6" }, "jest": { + "extensionsToTreatAsEsm": [ + ".ts" + ], "transform": { "^.+\\.(ts|tsx)$": [ "ts-jest", { - "tsconfig": "test/tsconfig.test.json" + "tsconfig": "test/tsconfig.test.json", + "useESM": true } ] }, diff --git a/scripts/build.mjs b/scripts/build.mjs index 862e23a59..42dee07ad 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -8,6 +8,9 @@ const sharedOptions = { minify: false, allowOverwrite: true, packages: "external", + format: "esm", + platform: "neutral", + target: "es2022", }; async function main() { @@ -18,8 +21,6 @@ async function main() { entryPoints: await glob(["./src/*.ts", "./src/**/*.ts"]), outdir: "pkg/dist-src", bundle: false, - platform: "neutral", - format: "esm", ...sharedOptions, sourcemap: false, }); @@ -33,29 +34,12 @@ async function main() { await rm(typeFile); } - const entryPoints = ["./pkg/dist-src/index.js"]; - - await Promise.all([ - // Build the a CJS Node.js bundle - esbuild.build({ - entryPoints, - outdir: "pkg/dist-node", - bundle: true, - platform: "node", - target: "node18", - format: "cjs", - ...sharedOptions, - }), - // Build an ESM browser bundle - esbuild.build({ - entryPoints, - outdir: "pkg/dist-web", - bundle: true, - platform: "browser", - format: "esm", - ...sharedOptions, - }), - ]); + await esbuild.build({ + entryPoints: ["./pkg/dist-src/index.js"], + outdir: "pkg/dist-bundle", + bundle: true, + ...sharedOptions, + }), // Copy the README, LICENSE to the pkg folder await copyFile("LICENSE", "pkg/LICENSE"); @@ -74,10 +58,8 @@ async function main() { { ...pkg, files: ["dist-*/**", "bin/**"], - main: "dist-node/index.js", - browser: "dist-web/index.js", - types: "dist-types/index.d.ts", - module: "dist-src/index.js", + exports: "./dist-bundle/index.js", + types: "./dist-types/index.d.ts", sideEffects: false, }, null, diff --git a/scripts/update-endpoints/code.mjs b/scripts/update-endpoints/code.mjs index de129e0d9..2ff9d3078 100644 --- a/scripts/update-endpoints/code.mjs +++ b/scripts/update-endpoints/code.mjs @@ -1,5 +1,4 @@ import { readFileSync, writeFileSync } from "node:fs"; -import { join } from "node:path"; import { fileURLToPath } from "node:url"; import { format } from "prettier"; @@ -11,13 +10,9 @@ const ENDPOINTS = JSON.parse( ); import { isDeprecated } from "./util.mjs"; -const ROUTES_PATH = join( - fileURLToPath(parentDir), - "..", - "..", - "src", - "generated", - "endpoints.ts", +const ROUTES_PATH = new URL( + "../../src/generated/endpoints.ts", + import.meta.url, ); const newRoutes = {}; @@ -132,5 +127,5 @@ async function generateRoutes() { { parser: "typescript" }, ), ); - console.log(`${ROUTES_PATH} written.`); + console.log(`${fileURLToPath(ROUTES_PATH)} written.`); } diff --git a/scripts/update-endpoints/docs.mjs b/scripts/update-endpoints/docs.mjs index b5c1b877d..bdcf97ee5 100644 --- a/scripts/update-endpoints/docs.mjs +++ b/scripts/update-endpoints/docs.mjs @@ -4,9 +4,7 @@ import { isDeprecated } from "./util.mjs"; import { readFileSync, mkdirSync, writeFileSync } from "node:fs"; const ENDPOINTS = JSON.parse( - readFileSync( - new URL("generated/endpoints.json", new URL(".", import.meta.url)), - ).toString(), + readFileSync(new URL("./generated/endpoints.json", import.meta.url), "utf-8"), ); generateRoutes(); diff --git a/scripts/update-endpoints/fetch-json.mjs b/scripts/update-endpoints/fetch-json.mjs index 6906ac765..33f3cbe06 100644 --- a/scripts/update-endpoints/fetch-json.mjs +++ b/scripts/update-endpoints/fetch-json.mjs @@ -1,6 +1,4 @@ import { writeFileSync } from "node:fs"; -import { resolve } from "node:path"; -import { fileURLToPath } from "node:url"; import graphql from "github-openapi-graphql-query"; import { format } from "prettier"; @@ -78,11 +76,7 @@ async function main() { }); writeFileSync( - resolve( - fileURLToPath(new URL(".", import.meta.url)), - "generated", - "endpoints.json", - ), + new URL("./generated/endpoints.json", import.meta.url), await format(JSON.stringify(endpoints), { parser: "json", }), diff --git a/scripts/update-endpoints/types.mjs b/scripts/update-endpoints/types.mjs index 3e0a958cd..c8c8a4be1 100644 --- a/scripts/update-endpoints/types.mjs +++ b/scripts/update-endpoints/types.mjs @@ -7,9 +7,7 @@ import { stringToJsdocComment } from "string-to-jsdoc-comment"; import sortKeys from "sort-keys"; const ENDPOINTS = JSON.parse( - readFileSync( - new URL("generated/endpoints.json", new URL(".", import.meta.url)), - ).toString(), + readFileSync(new URL("./generated/endpoints.json", import.meta.url), "utf-8"), ); import { isDeprecated } from "./util.mjs"; diff --git a/test/rest-endpoint-methods.test.ts b/test/rest-endpoint-methods.test.ts index 1d8179b81..cc6f10631 100644 --- a/test/rest-endpoint-methods.test.ts +++ b/test/rest-endpoint-methods.test.ts @@ -1,12 +1,13 @@ import { Octokit } from "@octokit/core"; import fetchMock from "fetch-mock"; +import { jest } from "@jest/globals"; import sinon from "sinon"; import { legacyRestEndpointMethods, restEndpointMethods, } from "../src/index.ts"; -import { Api } from "../src/types.ts"; +import type { Api } from "../src/types.ts"; describe("REST API endpoint methods", () => { it("README example", async () => { diff --git a/test/tsconfig.test.json b/test/tsconfig.test.json index 5e8dc2487..cf1f2005d 100644 --- a/test/tsconfig.test.json +++ b/test/tsconfig.test.json @@ -3,7 +3,6 @@ "compilerOptions": { "emitDeclarationOnly": false, "noEmit": true, - "verbatimModuleSyntax": false, "allowImportingTsExtensions": true }, "include": ["src/**/*"] diff --git a/test/typescript.test.ts b/test/typescript.test.ts index 8430e421f..60c5289b8 100644 --- a/test/typescript.test.ts +++ b/test/typescript.test.ts @@ -1,5 +1,8 @@ import { Octokit } from "@octokit/core"; -import { RestEndpointMethodTypes, restEndpointMethods } from "../src/index.ts"; +import { + type RestEndpointMethodTypes, + restEndpointMethods, +} from "../src/index.ts"; describe("Smoke test", () => { it("Get parameters type for octokit.rest.issues.updateLabel()", async () => { From e70a5a9ab25ff34a92ec068fd37ecab95d2d6abc Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Sun, 25 Feb 2024 16:40:08 -0500 Subject: [PATCH 2/2] build: remove bundle, package is already small --- scripts/build.mjs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index 42dee07ad..0a71dc79c 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -22,25 +22,20 @@ async function main() { outdir: "pkg/dist-src", bundle: false, ...sharedOptions, - sourcemap: false, + sourcemap: true, }); // Remove the types file from the dist-src folder const typeFiles = await glob([ "./pkg/dist-src/**/types.js.map", "./pkg/dist-src/**/types.js", + "./pkg/dist-src/generated/*-types.js", + "./pkg/dist-src/generated/*-types.js.map", ]); for (const typeFile of typeFiles) { await rm(typeFile); } - await esbuild.build({ - entryPoints: ["./pkg/dist-src/index.js"], - outdir: "pkg/dist-bundle", - bundle: true, - ...sharedOptions, - }), - // Copy the README, LICENSE to the pkg folder await copyFile("LICENSE", "pkg/LICENSE"); await copyFile("README.md", "pkg/README.md"); @@ -57,8 +52,8 @@ async function main() { JSON.stringify( { ...pkg, - files: ["dist-*/**", "bin/**"], - exports: "./dist-bundle/index.js", + files: ["dist-*/**"], + exports: "./dist-src/index.js", types: "./dist-types/index.d.ts", sideEffects: false, },