From bae363149a4f8a0abc99837c782370575d8c3bdc Mon Sep 17 00:00:00 2001 From: KyleBoyer Date: Tue, 23 Apr 2024 09:48:50 -0500 Subject: [PATCH 1/3] Added "default" export in package.json --- scripts/build.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build.mjs b/scripts/build.mjs index 74b256e..d833c93 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -66,6 +66,7 @@ async function main() { ".": { types: "./dist-types/index.d.ts", import: "./dist-bundle/index.js", + default: "./dist-bundle/index.js", }, }, sideEffects: false, From ba9bb3935a0d9a11b5f4438281bfb53f149f4af9 Mon Sep 17 00:00:00 2001 From: KyleBoyer Date: Tue, 23 Apr 2024 10:34:41 -0500 Subject: [PATCH 2/3] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 767debd..817dbea 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ import { retry } from "@octokit/plugin-retry"; +> [!IMPORTANT] +> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`. +> +> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).
+> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus) + ```js const MyOctokit = Octokit.plugin(retry); const octokit = new MyOctokit({ auth: "secret123" }); From c42683a61304cb6e18c04501bfd1febc56a7c33a Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 23 Apr 2024 16:30:30 -0400 Subject: [PATCH 3/3] remove main, add comment --- scripts/build.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index d833c93..e77e944 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -60,12 +60,14 @@ async function main() { { ...pkg, files: ["dist-*/**", "bin/**"], - main: "./dist-bundle/index.js", types: "./dist-types/index.d.ts", exports: { ".": { types: "./dist-types/index.d.ts", import: "./dist-bundle/index.js", + // Tooling currently are having issues with the "exports" field when there is no "default", ex: TypeScript, eslint, ncc, jest + // See https://github.com/octokit/core.js/issues/667#issuecomment-2037592361 + // See https://github.com/octokit/plugin-retry.js/issues/541 default: "./dist-bundle/index.js", }, },