Skip to content

Commit 2e5cdfc

Browse files
authored
fix(pkg): add a default fallback export (#379)
* docs: add note on needed config changes for TypeScript * fix(pkg): add a `default` fallback export * style: prettier * docs: update tsconfig changes * style: prettier
1 parent b5ced6c commit 2e5cdfc

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
@@ -38,6 +38,12 @@ import { requestLog } from "@octokit/plugin-request-log";
3838
</tbody>
3939
</table>
4040

41+
> [!IMPORTANT]
42+
> 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"`.
43+
>
44+
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
45+
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
46+
4147
```js
4248
const MyOctokit = Octokit.plugin(requestLog);
4349
const octokit = new MyOctokit({ auth: "secret123" });

scripts/build.mjs

Lines changed: 2 additions & 1 deletion
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)