diff --git a/README.md b/README.md index 622429c03..ed4c07002 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ import { Octokit } from "@octokit/core"; +As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json`. See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports). + ### REST API example ```js diff --git a/scripts/build.mjs b/scripts/build.mjs index 5e76ea9ee..8a25107a2 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -55,13 +55,16 @@ async function main() { { ...pkg, files: ["dist-*/**", "bin/**"], - main: "./dist-src/index.js", types: "./dist-types/index.d.ts", exports: { ".": { types: "./dist-types/index.d.ts", import: "./dist-src/index.js", + default: "./dist-src/index.js" }, + "./types": { + types: "./dist-types/types.d.ts" + } }, sideEffects: false, }, diff --git a/src/index.ts b/src/index.ts index 0dd0950ac..5be0a3662 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import { getUserAgent } from "universal-user-agent"; import type { HookCollection } from "before-after-hook"; import Hook from "before-after-hook"; import { request } from "@octokit/request"; -import { graphql, withCustomRequest } from "@octokit/graphql"; +import { type graphql, withCustomRequest } from "@octokit/graphql"; import { createTokenAuth } from "@octokit/auth-token"; import type {