From b678490a6d8674819f06856f38617f6392d13ff8 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Mon, 15 Apr 2024 20:06:57 -0400 Subject: [PATCH 1/3] fix(pkg): add a `default` fallback export See octokit/core.js#665 octokit/core.js#667 --- scripts/build.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index d7d9614c6..6b72228a9 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -53,12 +53,13 @@ async function main() { { ...pkg, files: ["dist-*/**"], - main: "./dist-src/index.js", types: "./dist-types/index.d.ts", exports: { ".": { import: "./dist-src/index.js", types: "./dist-types/index.d.ts", + // Tooling currently are having issues with the "exports" field when there is no "default", ex: TypeScript, eslint + default: "./dist-types/index.js", }, }, sideEffects: false, From e7d4341690cef03a7eced0f533e4b95a34685056 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Mon, 15 Apr 2024 20:07:26 -0400 Subject: [PATCH 2/3] docs: add note on needed config changes for TypeScript --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b9f015191..12ebe530c 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,9 @@ There is one method for each REST API endpoint documented at [https://developer. Parameter and response types for all endpoint methods exported as `{ RestEndpointMethodTypes }`. +> [!IMPORTANT] +> 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). + Example ```ts From f0aaee6f5edd3378e6f1078a5bb67d8745f62902 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Tue, 16 Apr 2024 14:03:22 -0400 Subject: [PATCH 3/3] docs(README): update info for typescript --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 12ebe530c..4ece5a43f 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,13 @@ There is one method for each REST API endpoint documented at [https://developer. ## TypeScript -Parameter and response types for all endpoint methods exported as `{ RestEndpointMethodTypes }`. - > [!IMPORTANT] -> 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). +> 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) + +Parameter and response types for all endpoint methods exported as `{ RestEndpointMethodTypes }`. Example