fix(pkg): add default condition to exports for CJS resolvers#23
Merged
khaliqgant merged 1 commit intomainfrom Apr 15, 2026
Merged
fix(pkg): add default condition to exports for CJS resolvers#23khaliqgant merged 1 commit intomainfrom
khaliqgant merged 1 commit intomainfrom
Conversation
The exports map declared only `types` and `import` conditions, which made CJS resolution fail with ERR_PACKAGE_PATH_NOT_EXPORTED when a CJS caller (or a tooling path-walker like tsx's resolveTsPaths) landed on the package. Adding a `default` condition pointing at the same ESM entry lets Node's CJS resolver find a match and then fail at load time with a clearer ESM-interop error instead of a misleading "no exports main defined". Functionally this does not make the package dual-mode — it's still `type: module` and the dist is ESM — but it closes the CJS resolution gap that was breaking downstream tsx users. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
defaultcondition to both.and./sdkexports, pointing at the same ESM entry asimport.type: moduleand dist is still ESM. This only closes a CJS resolution gap.Why
The exports map previously declared only
typesandimportconditions:When a CJS caller — or a tooling path-walker like
tsx'sresolveTsPaths— lands on this package, Node's CJS resolver picks condition set['require','node','default'], finds none of them, and errors withERR_PACKAGE_PATH_NOT_EXPORTED. That surfaced as a confusing "No 'exports' main defined" failure insideagent-relay run's tsx fallback, even though no code was actually trying torequire('agent-trajectories').With
defaultadded, the CJS resolver finds a target. If someone really does try torequire()the ESM build it will fail with a clearERR_REQUIRE_ESM, which is the expected ESM-interop error — much better than the misleading "no exports main" message.The companion fix on
AgentWorkforce/relay(#741) removes the tsx fallback in most cases by usingnode --experimental-strip-typesfirst. This PR is belt-and-suspenders for any other downstream that hits the same resolver path.Test plan
npm run buildstill passesnpm teststill passesrequire.resolve('agent-trajectories')no longer throwsERR_PACKAGE_PATH_NOT_EXPORTED🤖 Generated with Claude Code