Skip to content

fix(core): add explicit exports entry for nx/src/native directory#34967

Merged
FrozenPandaz merged 3 commits into
masterfrom
fix/nx-native-exports
Mar 23, 2026
Merged

fix(core): add explicit exports entry for nx/src/native directory#34967
FrozenPandaz merged 3 commits into
masterfrom
fix/nx-native-exports

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

Current Behavior

After the nodenext PR (#34111) added an exports map to packages/nx/package.json, the nx-cloud light client (ocean) fails to import nx/src/native.

The wildcard exports pattern "./src/*" resolves nx/src/native to ./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, getDbConnection is never assigned either, causing getDbConnection is not a function errors in CI.

This was not an issue with nx@22.7.0-beta.1 because that version had no exports map — Node fell back to normal CJS resolution which handles directory/index lookups.

Expected Behavior

require('nx/src/native') correctly resolves to dist/src/native/index.js via an explicit export entry, and the cloud client can load the native module and getDbConnection without errors.

Related Issue(s)

N/A — discovered during version bump CI failure investigation.

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.
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner March 23, 2026 18:55
@FrozenPandaz FrozenPandaz requested a review from AgentEnder March 23, 2026 18:55
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 23, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 7ee8299
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69c1a73f7eb98e0007b8b30b
😎 Deploy Preview https://deploy-preview-34967--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 23, 2026

Deploy Preview for nx-docs failed. Why did it fail? →

Name Link
🔨 Latest commit 7ee8299
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c1a73f2a4f1a0008dea608

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Mar 23, 2026

View your CI Pipeline Execution ↗ for commit 7ee8299

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 16m 14s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 8s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 7s View ↗
nx build workspace-plugin ✅ Succeeded 1m 26s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-23 21:11:27 UTC

@FrozenPandaz FrozenPandaz enabled auto-merge (squash) March 23, 2026 19:12
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]
nx-cloud[bot]

This comment was marked as outdated.

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]
nx-cloud[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

@FrozenPandaz FrozenPandaz disabled auto-merge March 23, 2026 23:03
@FrozenPandaz
Copy link
Copy Markdown
Contributor Author

These failures are unrelated

@FrozenPandaz FrozenPandaz merged commit d047b81 into master Mar 23, 2026
17 of 24 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/nx-native-exports branch March 23, 2026 23:03
@github-actions
Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants