Skip to content

Add a default condition to every export so require('apecs') resolves - #4

Open
srikarsunchu wants to merge 1 commit into
diffusionstudio:mainfrom
srikarsunchu:fix/exports-default-condition
Open

srikarsunchu wants to merge 1 commit into
diffusionstudio:mainfrom
srikarsunchu:fix/exports-default-condition

Conversation

@srikarsunchu

Copy link
Copy Markdown

Fixes #1.

What

Add a default condition to every exports entry (., ./react, ./solid, ./internal), pointing at the same ESM file as import. No CJS build.

Why

Each entry declared only types and import, so a CommonJS resolver found no match and threw ERR_PACKAGE_PATH_NOT_EXPORTED — Jest without ESM mode, ts-node in CJS mode, older bundler configs, plain require in a Node script — even though Node ≥ 20.19 (the engines floor) loads ESM through require().

Guard

scripts/check-bundle.mjs now resolves all four subpaths by package name (self-reference goes through the same exports map a consumer sees) and loads the entry with require(). With the condition present:

✓ 7 bundle(s): no dev paths, 3 entries with the expected surface

With it stripped back out:

✗ apecs does not resolve for require(): ERR_PACKAGE_PATH_NOT_EXPORTED
✗ apecs/react does not resolve for require(): ERR_PACKAGE_PATH_NOT_EXPORTED
✗ apecs/solid does not resolve for require(): ERR_PACKAGE_PATH_NOT_EXPORTED
✗ apecs/internal does not resolve for require(): ERR_PACKAGE_PATH_NOT_EXPORTED
✗ require("apecs") throws: ERR_PACKAGE_PATH_NOT_EXPORTED

Verified on Node 25; npm test unaffected (no source change).

🤖 Generated with Claude Code

Each exports entry declared only types and import, so a CommonJS resolver
found no match and threw ERR_PACKAGE_PATH_NOT_EXPORTED — for Jest without
ESM mode, ts-node in CJS mode, older bundler configs, and plain require in
a Node script — even though Node >= 20.19, the engines floor, can load the
ESM file through require(). Point default at the same ESM file for the root
and the react, solid and internal subpaths; no CJS build is needed.

check-bundle now resolves all four subpaths by package name through the
exports map and loads the entry with require(), so a missing condition
fails the post-build check instead of the first CJS consumer.

Fixes diffusionstudio#1

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

require('apecs') fails: exports map has no default/require condition

1 participant