Skip to content

Commit a1ab11e

Browse files
authored
fix(pkg): add default fallback and types export (#419)
* fix(pkg): add a default fallback See octokit/core.js#665 octokit/core.js#667 * docs: add note on needed config changes for TypeScript
1 parent 3a17551 commit a1ab11e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ import { RequestError } from "@octokit/request-error";
3535
</tbody>
3636
</table>
3737

38+
> [!IMPORTANT]
39+
> 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"`.
40+
>
41+
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
42+
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
43+
3844
```js
3945
const error = new RequestError("Oops", 500, {
4046
request: {

scripts/build.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ async function main() {
5050
{
5151
...pkg,
5252
files: ["dist-*/**", "bin/**"],
53-
main: "./dist-src/index.js",
5453
types: "./dist-types/index.d.ts",
5554
exports: {
5655
".": {
5756
types: "./dist-types/index.d.ts",
5857
import: "./dist-src/index.js",
58+
// Tooling currently are having issues with the "exports" field when there is no "default", ex: TypeScript, eslint
59+
default: "./dist-src/index.js",
5960
}
6061
},
6162
sideEffects: false,

0 commit comments

Comments
 (0)