From 069235f45a8b49f2bccdc9cc561ec7375d225eec Mon Sep 17 00:00:00 2001 From: wolfy1339 <4595477+wolfy1339@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:09:32 -0400 Subject: [PATCH] fix(pkg): add default fallback and types export (#612) * fix(pkg): add a default fallback See ocotkit/core.js#665 octokit/core.js#667 * docs: add note on needed config changes for TypeScript * fix(pkg): add an export for `dist-types/types.d.ts` --- README.md | 3 +++ scripts/build.mjs | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9ebf695f..3ac766a3 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,9 @@ function myPlugin(octokit, options) { } ``` +> [!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). + ## `octokit.paginate()` The `paginateRest` plugin adds a new `octokit.paginate()` method which accepts the same parameters as [`octokit.request`](https://github.com/octokit/request.js#request). Only "List ..." endpoints such as [List issues for a repository](https://developer.github.com/v3/issues/#list-issues-for-a-repository) are supporting pagination. Their [response includes a Link header](https://developer.github.com/v3/issues/#response-1). For other endpoints, `octokit.paginate()` behaves the same as `octokit.request()`. diff --git a/scripts/build.mjs b/scripts/build.mjs index d4be5308..98e7d3d0 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -62,14 +62,16 @@ async function main() { { ...pkg, files: ["dist-*/**", "bin/**"], - // Tooling currently are having issues with the "exports" field, ex: TypeScript, eslint - // We add a `main` and `types` field to the package.json for the time being - 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 + default: "./dist-bundle/index.js", + }, + "./types": { + types: "./dist-types/.d.ts", }, }, sideEffects: false,