Skip to content

Commit

Permalink
fix(pkg): add a default fallback export (#695)
Browse files Browse the repository at this point in the history
Co-authored-by: wolfy1339 <webmaster@wolfy1339.com>
  • Loading branch information
KyleBoyer and wolfy1339 authored Apr 23, 2024
1 parent d6abbcf commit 0f404fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ import { throttling } from "@octokit/plugin-throttling";
</tbody>
</table>

> [!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).<br>
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
The code below creates a "Hello, world!" issue on every repository in a given organization. Without the throttling plugin it would send many requests in parallel and would hit rate limits very quickly. But the `@octokit/plugin-throttling` slows down your requests according to the official guidelines, so you don't get blocked before your quota is exhausted.

The `throttle.onSecondaryRateLimit` and `throttle.onRateLimit` options are required. Return `true` to automatically retry the request after `retryAfter` seconds.
Expand Down
8 changes: 4 additions & 4 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ 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
// See https://github.com/octokit/core.js/pulls/662
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
// See https://github.com/octokit/core.js/issues/667#issuecomment-2037592361
// See https://github.com/octokit/plugin-throttling.js/issues/694
default: "./dist-bundle/index.js",
},
},
sideEffects: false,
Expand Down

0 comments on commit 0f404fb

Please sign in to comment.