Skip to content

fix(core): resolve published nx migrate package resolution#35013

Merged
FrozenPandaz merged 1 commit intomasterfrom
fix/core-published-nx-migrate-resolution
Mar 25, 2026
Merged

fix(core): resolve published nx migrate package resolution#35013
FrozenPandaz merged 1 commit intomasterfrom
fix/core-published-nx-migrate-resolution

Conversation

@leosvelperez
Copy link
Copy Markdown
Member

@leosvelperez leosvelperez commented Mar 25, 2026

Current Behavior

When nx migrate latest runs, it installs the target version of nx into a temporary directory and executes that published CLI. During migration, Nx checks whether nx is already installed in the workspace by resolving nx/package.json.

This used to resolve through the workspace-oriented lookup paths, so migrate correctly detected the workspace-installed nx package and expanded the first-party Nx package group.

That changed recently with chore(core): build nx to local dist and use nodenext (#34111). As part of that work, the published nx package gained an exports map. In Node, a package with name: "nx" and exports can self-reference by package name. As a result, when code running inside the temporary published nx package resolves nx/package.json, Node now resolves that request back to the temporary package itself.

The resolved path points outside the workspace root, so migrate's existing safety check treats nx as not installed in the workspace. Once that happens, migrate only updates nx and never expands the rest of the first-party Nx package group.

Separately, provenance package-group lookup assumes a source-layout-relative path to package.json, which does not hold for published artifacts built into local dist/.

Expected Behavior

Published temporary migrate CLIs should still resolve the workspace-installed nx package when migrate determines what is installed in the workspace. That preserves the existing package-group migration behavior even after the recent exports-based packaging change.

Provenance package-group lookup should resolve the manifest of the currently running nx package in a way that works for published artifacts as well as source checkouts.

@leosvelperez leosvelperez requested a review from a team as a code owner March 25, 2026 13:17
@leosvelperez leosvelperez requested a review from AgentEnder March 25, 2026 13:17
@leosvelperez leosvelperez self-assigned this Mar 25, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 25, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 49c9313
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69c3e076f176250008e9618d
😎 Deploy Preview https://deploy-preview-35013--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 25, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 49c9313
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c3e07670808b0008609a45
😎 Deploy Preview https://deploy-preview-35013--nx-docs.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.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Mar 25, 2026

View your CI Pipeline Execution ↗ for commit 49c9313

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 55m 29s 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 2m 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-25 14:24:58 UTC

@FrozenPandaz FrozenPandaz merged commit 0a38129 into master Mar 25, 2026
26 of 27 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/core-published-nx-migrate-resolution branch March 25, 2026 14:34
FrozenPandaz pushed a commit that referenced this pull request Mar 26, 2026
## Current Behavior

When `nx migrate latest` runs, it installs the target version of `nx`
into a temporary directory and executes that published CLI. During
migration, Nx checks whether `nx` is already installed in the workspace
by resolving `nx/package.json`.

This used to resolve through the workspace-oriented lookup paths, so
migrate correctly detected the workspace-installed `nx` package and
expanded the first-party Nx package group.

That changed recently with `chore(core): build nx to local dist and use
nodenext (#34111)`. As part of that work, the published `nx` package
gained an `exports` map. In Node, a package with `name: "nx"` and
`exports` can self-reference by package name. As a result, when code
running inside the temporary published `nx` package resolves
`nx/package.json`, Node now resolves that request back to the temporary
package itself.

The resolved path points outside the workspace root, so migrate's
existing safety check treats `nx` as not installed in the workspace.
Once that happens, migrate only updates `nx` and never expands the rest
of the first-party Nx package group.

Separately, provenance package-group lookup assumes a
source-layout-relative path to `package.json`, which does not hold for
published artifacts built into local `dist/`.

## Expected Behavior

Published temporary migrate CLIs should still resolve the
workspace-installed `nx` package when migrate determines what is
installed in the workspace. That preserves the existing package-group
migration behavior even after the recent `exports`-based packaging
change.

Provenance package-group lookup should resolve the manifest of the
currently running `nx` package in a way that works for published
artifacts as well as source checkouts.

(cherry picked from commit 0a38129)
@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 31, 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