Skip to content

fix: add default condition to subpath exports for CJS compatibility#161

Merged
HugoRCD merged 1 commit intoHugoRCD:mainfrom
spichen:cjs-fix
Mar 10, 2026
Merged

fix: add default condition to subpath exports for CJS compatibility#161
HugoRCD merged 1 commit intoHugoRCD:mainfrom
spichen:cjs-fix

Conversation

@spichen
Copy link
Copy Markdown

@spichen spichen commented Mar 9, 2026

🔗 Linked issue

Resolves #159

📚 Description

Node's CJS require() resolver does not match the "import" condition in package.json exports. This causes projects that compile to CommonJS (e.g. NestJS with SWC) to fail with:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './nestjs' is not defined
by "exports" in node_modules/evlog/package.json

This PR adds a "default" condition to each subpath export in package.json. The "default" condition acts as a universal fallback that both ESM import and CJS require() (Node 22+) can resolve against, without affecting existing ESM behavior.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 9, 2026

Someone is attempting to deploy a commit to the HRCD Projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the bug Something isn't working label Mar 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Thank you for following the naming conventions! 🙏

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 10, 2026

npm i https://pkg.pr.new/evlog@161
npm i https://pkg.pr.new/@evlog/nuxthub@161

commit: d58302b

@HugoRCD HugoRCD merged commit c97a180 into HugoRCD:main Mar 10, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] CJS projects cannot resolve subpath exports (evlog/nestjs, evlog/otlp, etc.)

2 participants