From 4986fb0d094e7e7d77f970f366a5fce7a9d55c55 Mon Sep 17 00:00:00 2001 From: wolfy1339 <4595477+wolfy1339@users.noreply.github.com> Date: Sun, 25 Feb 2024 15:54:00 -0500 Subject: [PATCH] feat: package is now ESM (#675) BREAKING CHANGE: package is now ESM --- package-lock.json | 121 ++++++++++++------------- package.json | 30 +++--- scripts/build.mjs | 39 +++----- scripts/update-endpoints/code.js | 8 +- scripts/update-endpoints/fetch-json.js | 14 +-- src/index.ts | 16 ++-- src/wrap-request.ts | 2 +- test/events.test.ts | 3 +- test/exports.test.ts | 2 +- test/octokit.ts | 2 +- test/plugin.test.ts | 4 +- test/retry.test.ts | 9 +- test/smoke.test.ts | 2 +- test/tsconfig.test.json | 2 +- test/typescript-validate.ts | 2 +- 15 files changed, 123 insertions(+), 133 deletions(-) diff --git a/package-lock.json b/package-lock.json index e3527cdd..bc297bfd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,18 +9,18 @@ "version": "0.0.0-development", "license": "MIT", "dependencies": { - "@octokit/types": "^12.2.0", + "@octokit/types": "^12.6.0", "bottleneck": "^2.15.3" }, "devDependencies": { - "@octokit/core": "^5.0.0", - "@octokit/request-error": "^5.0.0", - "@octokit/tsconfig": "^2.0.0", + "@octokit/core": "^6.0.0", + "@octokit/request-error": "^6.0.1", + "@octokit/tsconfig": "^3.0.0", "@types/fetch-mock": "^7.3.1", "@types/jest": "^29.0.0", "@types/node": "^20.0.0", "esbuild": "^0.20.0", - "fetch-mock": "^9.0.0", + "fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1", "github-openapi-graphql-query": "^4.0.0", "glob": "^10.2.6", "jest": "^29.0.0", @@ -34,7 +34,7 @@ "node": ">= 18" }, "peerDependencies": { - "@octokit/core": "^5.0.0" + "@octokit/core": "^6.0.0" } }, "node_modules/@ampproject/remapping": { @@ -1774,105 +1774,103 @@ } }, "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.1.0", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.1.0.tgz", - "integrity": "sha512-BDa2VAMLSh3otEiaMJ/3Y36GU4qf6GI+VivQ/P41NC6GHcdxpKlqV0ikSZ5gdQsmS3ojXeRx5vasgNTinF0Q4g==", + "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/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": "^2.2.0", - "universal-user-agent": "^6.0.0" + "before-after-hook": "^3.0.2", + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/endpoint": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.4.tgz", - "integrity": "sha512-DWPLtr1Kz3tv8L0UvXTDP1fNwM0S+z6EJpRcvH66orY6Eld4XBMCSYsaWp4xIm61jTWxK68BrR7ibO+vSDnZqw==", + "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": "^12.0.0", - "universal-user-agent": "^6.0.0" + "universal-user-agent": "^7.0.2" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/graphql": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz", - "integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==", + "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/request": "^9.0.0", "@octokit/types": "^12.0.0", - "universal-user-agent": "^6.0.0" + "universal-user-agent": "^7.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/openapi-types": { - "version": "19.1.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-19.1.0.tgz", - "integrity": "sha512-6G+ywGClliGQwRsjvqVYpklIfa7oRPA0vyhPQG/1Feh+B+wU0vGH1JiJ5T25d3g1JZYBHzR2qefLi9x8Gt+cpw==" + "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.2.0", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.2.0.tgz", - "integrity": "sha512-exPif6x5uwLqv1N1irkLG1zZNJkOtj8bZxuVHd71U5Ftuxf2wGNvAJyNBcPbPC+EBzwYEbBDdSFb8EPcjpYxPQ==", + "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/endpoint": "^10.0.0", + "@octokit/request-error": "^6.0.1", "@octokit/types": "^12.0.0", - "universal-user-agent": "^6.0.0" + "universal-user-agent": "^7.0.2" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/request-error": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", - "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", + "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": "^12.0.0", - "deprecation": "^2.0.0", - "once": "^1.4.0" + "@octokit/types": "^12.0.0" }, "engines": { "node": ">= 18" } }, "node_modules/@octokit/tsconfig": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-2.0.0.tgz", - "integrity": "sha512-tWnrai3quGt8+gRN2edzo9fmraWekeryXPeXDomMw2oFSpu/lH3VSWGn/q4V+rwjTRMeeXk/ci623/01Zet4VQ==", + "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.5.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.5.0.tgz", - "integrity": "sha512-YJEKcb0KkJlIUNU/zjnZwHEP8AoVh/OoIcP/1IyR4UHxExz7fzpe/a8IG4wBtQi7QDEqiomVLX88S6FpxxAJtg==", + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.6.0.tgz", + "integrity": "sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw==", "dependencies": { - "@octokit/openapi-types": "^19.1.0" + "@octokit/openapi-types": "^20.0.0" } }, "node_modules/@pkgjs/parseargs": { @@ -2334,9 +2332,9 @@ "dev": true }, "node_modules/before-after-hook": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", - "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==", + "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/bottleneck": { @@ -2897,12 +2895,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", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -3129,9 +3121,10 @@ } }, "node_modules/fetch-mock": { - "version": "9.11.0", - "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-9.11.0.tgz", - "integrity": "sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q==", + "name": "@gr2m/fetch-mock", + "version": "9.11.0-pull-request-644.1", + "resolved": "https://registry.npmjs.org/@gr2m/fetch-mock/-/fetch-mock-9.11.0-pull-request-644.1.tgz", + "integrity": "sha512-gTp6RCHzlOXS1qRb0APfuyz48Lw/JFPa4uiar+kEgL1STsDwth75HJZ4x30tBlXMJXV8XDTDzJ2Hz9w3RWiHJA==", "dev": true, "dependencies": { "@babel/core": "^7.0.0", @@ -6740,9 +6733,9 @@ "dev": true }, "node_modules/universal-user-agent": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", - "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==", + "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 7ea28250..f32fdb5e 100644 --- a/package.json +++ b/package.json @@ -4,37 +4,38 @@ "publishConfig": { "access": "public" }, + "type": "module", "description": "Octokit plugin for GitHub's recommended request throttling", "scripts": { "build": "node scripts/build.mjs && tsc -p tsconfig.json", "lint": "prettier --check '{src,scripts,test}/**/*' '!*/generated/**' README.md package.json", "lint:fix": "prettier --write '{src,scripts,test}/**/*' '!*/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", - "update-endpoints:code": "node scripts/update-endpoints/code", - "validate:ts": "npm run build && tsc --noEmit --noImplicitAny --target es2020 --esModuleInterop --moduleResolution node test/typescript-validate.ts" + "update-endpoints:fetch-json": "node scripts/update-endpoints/fetch-json.js", + "update-endpoints:code": "node scripts/update-endpoints/code.js", + "validate:ts": "tsc --noEmit --noImplicitAny --target es2022 --esModuleInterop --moduleResolution node16 --module node16 test/typescript-validate.ts" }, "repository": "github:octokit/plugin-throttling.js", "author": "Simon Grondin (http://github.com/SGrondin)", "license": "MIT", "dependencies": { - "@octokit/types": "^12.2.0", + "@octokit/types": "^12.6.0", "bottleneck": "^2.15.3" }, "peerDependencies": { - "@octokit/core": "^5.0.0" + "@octokit/core": "^6.0.0" }, "devDependencies": { - "@octokit/core": "^5.0.0", - "@octokit/request-error": "^5.0.0", - "@octokit/tsconfig": "^2.0.0", + "@octokit/core": "^6.0.0", + "@octokit/request-error": "^6.0.1", + "@octokit/tsconfig": "^3.0.0", "@types/fetch-mock": "^7.3.1", "@types/jest": "^29.0.0", "@types/node": "^20.0.0", "esbuild": "^0.20.0", - "fetch-mock": "^9.0.0", + "fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1", "github-openapi-graphql-query": "^4.0.0", "glob": "^10.2.6", "jest": "^29.0.0", @@ -45,11 +46,15 @@ "typescript": "^5.0.0" }, "jest": { + "extensionsToTreatAsEsm": [ + ".ts" + ], "transform": { "^.+\\.(ts|tsx)$": [ "ts-jest", { - "tsconfig": "test/tsconfig.test.json" + "tsconfig": "test/tsconfig.test.json", + "useESM": true } ] }, @@ -60,6 +65,9 @@ "functions": 100, "lines": 100 } + }, + "moduleNameMapper": { + "^(.+)\\.jsx?$": "$1" } }, "release": { diff --git a/scripts/build.mjs b/scripts/build.mjs index 862e23a5..3363b684 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -35,27 +35,14 @@ async function main() { 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, + outdir: "pkg/dist-bundle", + bundle: true, + platform: "neutral", + format: "esm", + ...sharedOptions, + }); // Copy the README, LICENSE to the pkg folder await copyFile("LICENSE", "pkg/LICENSE"); @@ -74,10 +61,12 @@ 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: { + ".": { + types: "./dist-types/index.d.ts", + import: "./dist-bundle/index.js", + }, + }, sideEffects: false, }, null, diff --git a/scripts/update-endpoints/code.js b/scripts/update-endpoints/code.js index 08250a61..a7fcbd57 100644 --- a/scripts/update-endpoints/code.js +++ b/scripts/update-endpoints/code.js @@ -4,11 +4,13 @@ * trigger notifications. So instead we automatically generate a file that * only contains these paths when @octokit/openapi has a new release. */ -const { writeFileSync } = require("fs"); +import { writeFileSync, readFileSync } from "node:fs"; -const prettier = require("prettier"); +import prettier from "prettier"; -const ENDPOINTS = require("./generated/endpoints.json"); +const ENDPOINTS = JSON.parse( + readFileSync(new URL("./generated/endpoints.json", import.meta.url), "utf-8"), +); const paths = []; for (const endpoint of ENDPOINTS) { diff --git a/scripts/update-endpoints/fetch-json.js b/scripts/update-endpoints/fetch-json.js index d1b11048..028edd61 100644 --- a/scripts/update-endpoints/fetch-json.js +++ b/scripts/update-endpoints/fetch-json.js @@ -1,7 +1,6 @@ -const { writeFileSync } = require("fs"); -const path = require("path"); +import { writeFileSync } from "node:fs"; -const graphql = require("github-openapi-graphql-query"); +import graphql from "github-openapi-graphql-query"; if (!process.env.VERSION) { throw new Error("VERSION environment variable must be set"); @@ -21,14 +20,11 @@ const QUERY = ` main(); async function main() { - const { - data: { endpoints }, - } = await graphql(QUERY, { - version, - }); + const res = await graphql(QUERY, { version }); + const endpoints = res.data.endpoints; writeFileSync( - path.resolve(__dirname, "generated", "endpoints.json"), + new URL("./generated/endpoints.json", import.meta.url), JSON.stringify(endpoints, null, 2) + "\n", ); } diff --git a/src/index.ts b/src/index.ts index 661ae773..2326f1ba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,13 +2,13 @@ import BottleneckLight from "bottleneck/light"; import type TBottleneck from "bottleneck"; import { Octokit } from "@octokit/core"; -import type { OctokitOptions } from "@octokit/core/dist-types/types.d"; -import type { Groups, State, ThrottlingOptions } from "./types"; -import { VERSION } from "./version"; +import type { OctokitOptions } from "@octokit/core"; +import type { Groups, State, ThrottlingOptions } from "./types.js"; +import { VERSION } from "./version.js"; -import { wrapRequest } from "./wrap-request"; -import triggersNotificationPaths from "./generated/triggers-notification-paths"; -import { routeMatcher } from "./route-matcher"; +import { wrapRequest } from "./wrap-request.js"; +import triggersNotificationPaths from "./generated/triggers-notification-paths.js"; +import { routeMatcher } from "./route-matcher.js"; import type { EndpointDefaults, OctokitResponse } from "@octokit/types"; // Workaround to allow tests to directly access the triggersNotification function. @@ -191,7 +191,7 @@ export function throttling(octokit: Octokit, octokitOptions: OctokitOptions) { // the types expect that the function can return either a Promise of the response, or directly return the response. // This is due to the fact that `@octokit/request` uses aysnc functions // Also, since we add the custom `retryCount` property to the request argument, the types are not compatible. - // @ts-expect-error + // @ts-ignore We use the ignore instead of expect-error because TypeScript cannot make up it's mind if there is an error or not. octokit.hook.wrap("request", wrapRequest.bind(null, state)); return {}; @@ -199,7 +199,7 @@ export function throttling(octokit: Octokit, octokitOptions: OctokitOptions) { throttling.VERSION = VERSION; throttling.triggersNotification = triggersNotification; -declare module "@octokit/core/dist-types/types.d" { +declare module "@octokit/core" { interface OctokitOptions { throttle?: ThrottlingOptions; } diff --git a/src/wrap-request.ts b/src/wrap-request.ts index b7689c45..6665c122 100644 --- a/src/wrap-request.ts +++ b/src/wrap-request.ts @@ -1,5 +1,5 @@ import type { EndpointDefaults, OctokitResponse } from "@octokit/types"; -import type { State } from "./types"; +import type { State } from "./types.js"; const noop = () => Promise.resolve(); diff --git a/test/events.test.ts b/test/events.test.ts index 16e8a16b..b0718d62 100644 --- a/test/events.test.ts +++ b/test/events.test.ts @@ -1,4 +1,5 @@ -import { TestOctokit } from "./octokit"; +import { TestOctokit } from "./octokit.ts"; +import { jest } from "@jest/globals"; describe("Events", function () { it("Should support non-limit 403s", async function () { diff --git a/test/exports.test.ts b/test/exports.test.ts index 6d330023..28ecc0bc 100644 --- a/test/exports.test.ts +++ b/test/exports.test.ts @@ -1,4 +1,4 @@ -import type { ThrottlingOptions } from "../src"; +import type { ThrottlingOptions } from "../src/index.ts"; import type { Octokit } from "@octokit/core"; describe("Exports", function () { diff --git a/test/octokit.ts b/test/octokit.ts index 41bc93c8..f00c0e6e 100644 --- a/test/octokit.ts +++ b/test/octokit.ts @@ -1,6 +1,6 @@ import { Octokit } from "@octokit/core"; import { RequestError } from "@octokit/request-error"; -import { throttling } from "../src"; +import { throttling } from "../src/index.ts"; function testPlugin(octokit: Octokit) { const t0 = Date.now(); diff --git a/test/plugin.test.ts b/test/plugin.test.ts index 7b401450..268e0a54 100644 --- a/test/plugin.test.ts +++ b/test/plugin.test.ts @@ -1,6 +1,6 @@ import Bottleneck from "bottleneck"; -import { TestOctokit } from "./octokit"; -import { throttling } from "../src"; +import { TestOctokit } from "./octokit.ts"; +import { throttling } from "../src/index.ts"; describe("General", function () { it("Should be possible to disable the plugin", async function () { diff --git a/test/retry.test.ts b/test/retry.test.ts index ced754e3..ef71521e 100644 --- a/test/retry.test.ts +++ b/test/retry.test.ts @@ -1,9 +1,10 @@ import Bottleneck from "bottleneck"; -import { TestOctokit } from "./octokit"; +import { TestOctokit } from "./octokit.ts"; import { Octokit } from "@octokit/core"; -import { throttling } from "../src"; -import { AddressInfo } from "net"; -import { createServer } from "http"; +import { throttling } from "../src/index.ts"; +import type { AddressInfo } from "node:net"; +import { createServer } from "node:http"; +import { jest } from "@jest/globals"; jest.setTimeout(20000); diff --git a/test/smoke.test.ts b/test/smoke.test.ts index 1cdf1ae5..9babb53c 100644 --- a/test/smoke.test.ts +++ b/test/smoke.test.ts @@ -1,4 +1,4 @@ -import { throttling } from "../src"; +import { throttling } from "../src/index.ts"; describe("Smoke test", () => { it("is a function", () => { diff --git a/test/tsconfig.test.json b/test/tsconfig.test.json index b0961e18..cf1f2005 100644 --- a/test/tsconfig.test.json +++ b/test/tsconfig.test.json @@ -3,7 +3,7 @@ "compilerOptions": { "emitDeclarationOnly": false, "noEmit": true, - "verbatimModuleSyntax": false + "allowImportingTsExtensions": true }, "include": ["src/**/*"] } diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts index 11024114..7afefb33 100644 --- a/test/typescript-validate.ts +++ b/test/typescript-validate.ts @@ -1,5 +1,5 @@ import { Octokit } from "@octokit/core"; -import { throttling } from "../pkg"; +import { throttling } from "../src/index.js"; // ************************************************************ // THIS CODE IS NOT EXECUTED. IT IS FOR TYPECHECKING ONLY // ************************************************************