Skip to content

Commit 0f404fb

Browse files
KyleBoyerwolfy1339
andauthored
fix(pkg): add a default fallback export (#695)
Co-authored-by: wolfy1339 <[email protected]>
1 parent d6abbcf commit 0f404fb

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ import { throttling } from "@octokit/plugin-throttling";
4242
</tbody>
4343
</table>
4444

45+
> [!IMPORTANT]
46+
> 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"`.
47+
>
48+
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
49+
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
50+
4551
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.
4652

4753
The `throttle.onSecondaryRateLimit` and `throttle.onRateLimit` options are required. Return `true` to automatically retry the request after `retryAfter` seconds.

scripts/build.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ async function main() {
6161
{
6262
...pkg,
6363
files: ["dist-*/**", "bin/**"],
64-
// Tooling currently are having issues with the "exports" field, ex: TypeScript, eslint
65-
// We add a `main` and `types` field to the package.json for the time being
66-
// See https://github.com/octokit/core.js/pulls/662
67-
main: "dist-bundle/index.js",
6864
types: "dist-types/index.d.ts",
6965
exports: {
7066
".": {
7167
types: "./dist-types/index.d.ts",
7268
import: "./dist-bundle/index.js",
69+
// Tooling currently are having issues with the "exports" field when there is no "default", ex: TypeScript, eslint, ncc
70+
// See https://github.com/octokit/core.js/issues/667#issuecomment-2037592361
71+
// See https://github.com/octokit/plugin-throttling.js/issues/694
72+
default: "./dist-bundle/index.js",
7373
},
7474
},
7575
sideEffects: false,

0 commit comments

Comments
 (0)