Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

Dual ESM/CJS Publish in 2026: A Modern tsconfig + package.json Setup That Just Works

DEV Community·Gabriel Anhaia·25 days ago
#YwU28TbE
#typescript#esm#cjs#json#package#dist
Reading 0:00
15s threshold

Book: TypeScript in Production — Tooling, Build, and Library Authoring Across Runtimes 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 A team I talked to shipped a TypeScript utility library to npm last quarter. It built. It published. The tests passed in their monorepo. Then external users started filing issues. One user reported that require('@team/core') returned an empty object in Node 20. Another reported that Vitest could not resolve the types and threw Cannot find module '@team/core' . A third said Bun loaded the package fine but imported the wrong file. Same package, four runtimes, four behaviors. That library had a main field, a module field, a types field, and one dist directory. In 2018 that was enough. In 2026 it is the shape that produces the four-issue welcome above.…

Continue reading — create a free account

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

Read More