Menu

1 / 2

The package.json exports Map Is the Most Important File You're Writing Wrong

DEV Community·Gabriel Anhaia·6 months ago
#ag6xW4KK
#typescript#javascript#exports#dist#types
Reading 0:00
15s threshold

Book: TypeScript in Production

Also by me: The TypeScript Library — the 5-book collection

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

Picture the morning after a 1.0 cut. A library that sat at 0.x for a couple of years finally ships its first stable. Release notes are short, the publish was clean, and the maintainer went to bed.

By breakfast the GitHub issues page is full. Hypothetical but typical: a consumer reports that @you/lib/parser cannot be found or has no type declarations. Another hits ERR_REQUIRE_ESM after upgrading. A third sees types resolve to any under moduleResolution: "node16" . A fourth finds the subpath import broken in their Jest setup.

The fix is one file. Not the source. The package.json . Specifically the exports map. Two problems in fewer than thirty lines of JSON: the types condition is below import , and the dual-mode subpath has no require condition.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.