Skip to content

chore: drop CJS build output, publish ESM-only - #38

Merged
frederikprijck merged 3 commits into
mainfrom
worktree-drop-cjs
Jul 29, 2026
Merged

frederikprijck merged 3 commits into
mainfrom
worktree-drop-cjs

Conversation

@frederikprijck

@frederikprijck frederikprijck commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Both @auth0/auth0-express and @auth0/auth0-express-api now build and publish ESM-only:
    • tsup.config.ts deleted for both packages; the build/build:watch scripts now run plain tsc --project tsconfig.build.json instead. Once a package is ESM-only, tsc with module: NodeNext already produces valid output, so tsup's bundling wasn't buying anything.
    • package.json for both: removed the module field and the require export condition, dropped the tsup devDependency. main and the import/default export conditions now all point at the ESM entry (./dist/index.js).
    • Added a tsconfig.build.json per package (extends the base tsconfig.json, excludes *.spec.ts and test-utils) so the build only emits library source, not test files.
    • Moved sourceMap: true into the base tsconfig.json (previously provided by tsup).
  • CJS consumers are unaffected in practice — neither package uses top-level await, so Node's native require(esm) support (stable since Node ^20.19.0 || ^22.12.0, and Node 24+) resolves the ESM build transparently via the default export condition.

Test plan

  • npm run build succeeds for both packages, producing ESM-only output (per-file .js/.d.ts, no .cjs, no leaked spec/test-utils files)
  • node -e "require(...)" and node -e "import(...)" smoke tests both resolve the built packages correctly under Node 24
  • npm run test passes across the monorepo (266 tests in the two packages, plus example app tests)
  • npm run lint passes across the monorepo

Node's native require(esm) support means CJS consumers can already
require() an ESM package directly, so shipping a separate CJS build
is no longer necessary. Removes the "require" export condition and
module field, and points main/import/default at the ESM output.
Now that both packages are ESM-only, tsup's bundling wasn't buying
anything beyond what tsc already does with NodeNext modules. Adds a
tsconfig.build.json (excludes specs/test-utils) so builds stay
declaration-per-file instead of pulling in test code, and moves
sourceMap into the base tsconfig since tsup previously provided it.
Comment thread packages/auth0-express/package.json
Adds engines field to both packages specifying minimum Node.js version
requirement for ESM-only distribution.
@frederikprijck
frederikprijck merged commit f7d2366 into main Jul 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants