From 2cab8e23b39546e4ad0c2fa3289c71ca54ff90dd Mon Sep 17 00:00:00 2001 From: KyleBoyer Date: Tue, 23 Apr 2024 15:18:42 -0500 Subject: [PATCH] fix(pkg): add a `default` fallback export (#195) Co-authored-by: wolfy1339 --- README.md | 6 ++++++ scripts/build.mjs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 48b094d..04dbf06 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ import { paginateGraphQL } from "@octokit/plugin-paginate-graphql"; +> [!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(paginateGraphQL); const octokit = new MyOctokit({ auth: "secret123" }); diff --git a/scripts/build.mjs b/scripts/build.mjs index fd19bf8..b894245 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -60,12 +60,13 @@ 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 + default: "./dist-bundle/index.js", } }, sideEffects: false,