You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide some option to set moduleResolution to node16 with CJS build #62
Recent node.js versions can understand conditional exports and subpath exports in package.json. And there are many packages using it even though it is commonjs-only. To use those exports in commonjs, moduleResolution need to be at least node16.
There are types at '.../node_modules/@opentelemetry/semantic-conventions/build/src/index-incubating.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.
... } from '@opentelemetry/semantic-conventions/incubating';
So... could this kind of option be added?
{
"zshy": {
+ "cjs": "node16" // can be one of `true`, `false` and `"node16"`
}
I went into zshy and changed this behavior, but the tests are failing because it inhibits relative imports without file extensions, which is quite common in CJS projects. That being said, you're supposed to be writing with ESM in mind if you want to use zshy, so I'm not really clear on why this is a concern.
The worst symptom, though, may be that zshy won't build a project that imports (via package.jsonexports) from another project built with zshy which seems ...bad. Neither Node.js nor TS (with appropriate moduleResolution) prevents this sort of require('package/exportName') in CJS from happening.
Attempting to use the module's real path (e.g., whatever @opentelementry/semantic-conventions/incubating points to, with file extension) could work for CJS (untested), but such an import seems like it'd break ESM because Node.js won't allow such a thing.
Setting module to CommonJS and moduleResolution to Node10 sure looks intentional though. Would need @colinhacks to weigh in here.
Workaround: don't try to import from paths defined in package.json's exports field; stick to importing from main. Not always doable, though--especially if the package you're trying to import from ain't yours!
Eager to send a PR to address this, if it would be accepted. Either breaking change or opt-in?
Activity
boneskull commentedon Jan 11, 2026
I went into zshy and changed this behavior, but the tests are failing because it inhibits relative imports without file extensions, which is quite common in CJS projects. That being said, you're supposed to be writing with ESM in mind if you want to use zshy, so I'm not really clear on why this is a concern.
The worst symptom, though, may be that zshy won't build a project that imports (via
package.jsonexports) from another project built with zshy which seems ...bad. Neither Node.js nor TS (with appropriatemoduleResolution) prevents this sort ofrequire('package/exportName')in CJS from happening.Attempting to use the module's real path (e.g., whatever
@opentelementry/semantic-conventions/incubatingpoints to, with file extension) could work for CJS (untested), but such an import seems like it'd break ESM because Node.js won't allow such a thing.Setting
moduletoCommonJSandmoduleResolutiontoNode10sure looks intentional though. Would need @colinhacks to weigh in here.Workaround: don't try to import from paths defined in
package.json'sexportsfield; stick to importing frommain. Not always doable, though--especially if the package you're trying to import from ain't yours!Eager to send a PR to address this, if it would be accepted. Either breaking change or opt-in?