-
Notifications
You must be signed in to change notification settings - Fork 31
[bug] CJS projects cannot resolve subpath exports (evlog/nestjs, evlog/otlp, etc.) #159
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
Problem
All subpath exports in evlog only define an "import" condition:
"./nestjs": {
"types": "./dist/nestjs/index.d.mts",
"import": "./dist/nestjs/index.mjs"
}
Node's CJS require() resolver does not match the "import" condition, so any project that compiles to CommonJS (e.g. NestJS with SWC, which is NestJS's default compiler) gets:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './nestjs' is not defined
by "exports" in node_modules/evlog/package.json
This affects all subpath exports, not just ./nestjs.
Expected behavior
require('evlog/nestjs') should resolve successfully in CJS projects, since Node 22+ can require() .mjs files when the export condition matches.
Suggested fix
Add a "default" condition to each subpath export. This is the lowest-effort fix and works for both ESM import and CJS require() on Node 22+:
"./nestjs": {
"types": "./dist/nestjs/index.d.mts",
"import": "./dist/nestjs/index.mjs",
"default": "./dist/nestjs/index.mjs"
}
Reproduction
evlog: 2.4.1
Node: 22.14.0
NestJS 11 with SWC (compiles to CJS by default)
Logs
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working