Skip to content

Commit 81720c7

Browse files
authored
fix(pkg): add a default fallback export (#733)
* fix(pkg): add a `default` fallback export See octokit/core.js#665 octokit/core.js#667 * docs: add note on needed config changes for TypeScript
1 parent 85bf1df commit 81720c7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ There is one method for each REST API endpoint documented at [https://developer.
5050

5151
## TypeScript
5252

53+
> [!IMPORTANT]
54+
> 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"`.
55+
>
56+
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
57+
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
58+
5359
Parameter and response types for all endpoint methods exported as `{ RestEndpointMethodTypes }`.
5460

5561
Example

scripts/build.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ async function main() {
5353
{
5454
...pkg,
5555
files: ["dist-*/**"],
56-
main: "./dist-src/index.js",
5756
types: "./dist-types/index.d.ts",
5857
exports: {
5958
".": {
6059
import: "./dist-src/index.js",
6160
types: "./dist-types/index.d.ts",
61+
// Tooling currently are having issues with the "exports" field when there is no "default", ex: TypeScript, eslint
62+
default: "./dist-types/index.js",
6263
},
6364
},
6465
sideEffects: false,

0 commit comments

Comments
 (0)