Confused about the `exports` field in package.json? I wrote a guide to break it down and walk you through it! 👉 hirok.io/posts/node-exports-guide
16 reposts97 likes
Confused about the `exports` field in package.json? I wrote a guide to break it down and walk you through it! 👉 hirok.io/posts/node-exports-guide
16 reposts97 likes
This is a useful deep dive into the boundary a package exposes. Related context: bsky.app/profile/kind... — explicit subpath exports protect consumers from accidental deep imports while keeping ESM/CommonJS entry points intentional.
Nice post! Slightly adjacent but also useful is this tool by @andrewbran.ch which checks the state of types on a package.json - I've found it super helpful! arethetypeswrong.github.io
Thanks John! And great idea 🙌 Just added a section for it: hirok.io/posts/node-e...
Nice article! FYI we are looking into better documenting the package shipping patterns with a repo full of examples, especially to come out with ESM upgrade guides with require(esm) rolling out to LTS soon github.com/nodejs/packa... will also take some notes from this post!
There were a lot of ideas discussed from the collab summit last week (notes github.com/openjs-found...) planning to getting the ball rolling in the following weeks…
Think it might be worth mentioning in the TS section that types must be first. For example, if you export types + ESM + CJS, the order must be "types, module, default". Also worth maybe mentioning this tool for validation of types + export conditions arethetypeswrong.github.io By @andrewbran.ch
Really good points! I addressed them all - hirok.io/posts/node-e... - hirok.io/posts/node-e... BTW `types` must be nested inside `require` and `import`. Exports with keys types, import, default was the classic mistake everyone made 😵💫
Hmm, I've used "types, import, default" and it seemed to work well? It's also used by eg preconstruct.tools Can you elaborate or point me to some resource on why it's wrong?
Guess who got lucky today, @jamie.build 😄 bsky.app/profile/jami...
This might be the post that finally gets me to learn how package.json#exports works
Thanks! I want to keep this beginner friendly guide on exports, and I felt like that would be advanced and less focused on exports FYI here's the exports alternative to typesVersion: www.typescriptlang.org/docs/handboo...