fix(core): add explicit exports entry for nx/src/native directory#34967
Conversation
The nx-cloud light client imports `nx/src/native` via package specifier. Since `src/native` is a directory (with index.js), the wildcard exports pattern `./src/*` resolves to `./dist/src/native.js` instead of `./dist/src/native/index.js`. Node's exports map doesn't do directory index resolution like CJS require does. This causes the native module import to fail silently in the cloud client's try/catch, which cascades to `getDbConnection is not a function` errors in CI.
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ Deploy Preview for nx-docs failed. Why did it fail? →
|
|
View your CI Pipeline Execution ↗ for commit 7ee8299
☁️ Nx Cloud last updated this comment at |
The nx-cloud light client imports `nx/src/native` via package specifier. Since `src/native` is a directory (with index.js), the wildcard exports pattern `./src/*` resolves to `./dist/src/native.js` instead of `./dist/src/native/index.js`. Node's exports map doesn't do directory index resolution like CJS require does. This causes the native module import to fail silently in the cloud client's try/catch, which cascades to `getDbConnection is not a function` errors in CI. [Self-Healing CI Rerun]
The nx-cloud light client imports `nx/src/native` via package specifier. Since `src/native` is a directory (with index.js), the wildcard exports pattern `./src/*` resolves to `./dist/src/native.js` instead of `./dist/src/native/index.js`. Node's exports map doesn't do directory index resolution like CJS require does. This causes the native module import to fail silently in the cloud client's try/catch, which cascades to `getDbConnection is not a function` errors in CI. [Self-Healing CI Rerun]
There was a problem hiding this comment.
Nx Cloud has identified a possible root cause for your failed CI:
We identified that the failing task e2e-nx:e2e-ci--src/workspace-legacy.test.ts is unrelated to this PR's changes, which only add an explicit ./src/native exports entry to packages/nx/package.json. The same Cypress [HMR] Hot Module Replacement is disabled error is reproducible on the master branch, confirming this is a pre-existing infrastructure issue and not a regression introduced here.
No code changes were suggested for this issue.
Trigger a rerun:
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
|
These failures are unrelated |
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
After the nodenext PR (#34111) added an
exportsmap topackages/nx/package.json, the nx-cloud light client (ocean) fails to importnx/src/native.The wildcard exports pattern
"./src/*"resolvesnx/src/nativeto./dist/src/native.js— but the actual file is./dist/src/native/index.js(it's a directory with an index file). Node's exports map does literal*substitution and does not perform CJS-style directory/index resolution.The cloud client wraps all its nx imports in a single try/catch, so when the native import fails,
getDbConnectionis never assigned either, causinggetDbConnection is not a functionerrors in CI.This was not an issue with
nx@22.7.0-beta.1because that version had noexportsmap — Node fell back to normal CJS resolution which handles directory/index lookups.Expected Behavior
require('nx/src/native')correctly resolves todist/src/native/index.jsvia an explicit export entry, and the cloud client can load the native module andgetDbConnectionwithout errors.Related Issue(s)
N/A — discovered during version bump CI failure investigation.