Skip to content

Commit

Permalink
fix(pkg): add default fallback and types export (#419)
Browse files Browse the repository at this point in the history
* fix(pkg): add a default fallback

See octokit/core.js#665 octokit/core.js#667

* docs: add note on needed config changes for TypeScript
  • Loading branch information
wolfy1339 committed Apr 16, 2024
1 parent 3a17551 commit a1ab11e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -35,6 +35,12 @@ import { RequestError } from "@octokit/request-error";
</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)
```js
const error = new RequestError("Oops", 500, {
request: {
Expand Down
3 changes: 2 additions & 1 deletion scripts/build.mjs
Expand Up @@ -50,12 +50,13 @@ async function main() {
{
...pkg,
files: ["dist-*/**", "bin/**"],
main: "./dist-src/index.js",
types: "./dist-types/index.d.ts",
exports: {
".": {
types: "./dist-types/index.d.ts",
import: "./dist-src/index.js",
// Tooling currently are having issues with the "exports" field when there is no "default", ex: TypeScript, eslint
default: "./dist-src/index.js",
}
},
sideEffects: false,
Expand Down

0 comments on commit a1ab11e

Please sign in to comment.