Skip to content

chore(repo): update nx to 23.0.0-beta.7#35565

Merged
FrozenPandaz merged 4 commits into
masterfrom
upnx
May 5, 2026
Merged

chore(repo): update nx to 23.0.0-beta.7#35565
FrozenPandaz merged 4 commits into
masterfrom
upnx

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

@FrozenPandaz FrozenPandaz commented May 5, 2026

Updating Nx from 23.0.0-beta.4 to 23.0.0-beta.7

@FrozenPandaz FrozenPandaz requested a review from a team as a code owner May 5, 2026 02:10
@FrozenPandaz FrozenPandaz requested a review from leosvelperez May 5, 2026 02:10
@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 8cfd0de
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69fa33db07ccf500082f91b9
😎 Deploy Preview https://deploy-preview-35565--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 May 5, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 8cfd0de
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69fa33dabb8c2500083d071a
😎 Deploy Preview https://deploy-preview-35565--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 May 5, 2026

View your CI Pipeline Execution ↗ for commit 8cfd0de

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 33m 45s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 18s View ↗
nx build workspace-plugin ✅ Succeeded 2m 3s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 25s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 7s View ↗
nx affected -t e2e-macos-local --parallel=1 --b... ✅ Succeeded 46m 49s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-05 19:09:00 UTC

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.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We fixed three test failures caused by the update-devkit-deep-imports migration changes. The devkit implementation was extended to also process @nx/devkit/internal imports (not just @nx/devkit/src/…), the nuxt test mock was updated to spread jest.requireActual so only loadConfigFile is overridden, and the workspace-plugin snapshot was updated to reflect the new multi-line import structure produced by the updated template.

Note

We are verifying this fix by re-running a subset of the 3 failed tasks that were analyzed.

Suggested Fix changes
diff --git a/packages/devkit/src/migrations/update-23-0-0/update-deep-imports.ts b/packages/devkit/src/migrations/update-23-0-0/update-deep-imports.ts
index e0381173..b22f6589 100644
--- a/packages/devkit/src/migrations/update-23-0-0/update-deep-imports.ts
+++ b/packages/devkit/src/migrations/update-23-0-0/update-deep-imports.ts
@@ -83,7 +83,11 @@ export default async function updateDevkitDeepImports(
       return;
     }
     const original = tree.read(filePath, 'utf-8');
-    if (!original || !original.includes(DEEP_IMPORT_PREFIX)) {
+    if (
+      !original ||
+      (!original.includes(DEEP_IMPORT_PREFIX) &&
+        !original.includes(INTERNAL_SPECIFIER))
+    ) {
       return;
     }
     const updated = rewriteDevkitDeepImports(original);
@@ -117,7 +121,11 @@ export function rewriteDevkitDeepImports(source: string): string {
   for (const stmt of sourceFile.statements) {
     if (!ts.isImportDeclaration(stmt)) continue;
     if (!ts.isStringLiteral(stmt.moduleSpecifier)) continue;
-    if (!stmt.moduleSpecifier.text.startsWith(DEEP_IMPORT_PREFIX)) continue;
+    if (
+      !stmt.moduleSpecifier.text.startsWith(DEEP_IMPORT_PREFIX) &&
+      stmt.moduleSpecifier.text !== INTERNAL_SPECIFIER
+    )
+      continue;
 
     const replacement = buildReplacement(stmt, sourceFile);
     changes.push(
diff --git a/packages/nuxt/src/plugins/plugin.spec.ts b/packages/nuxt/src/plugins/plugin.spec.ts
index 11eb31eb..e1a0f6c7 100644
--- a/packages/nuxt/src/plugins/plugin.spec.ts
+++ b/packages/nuxt/src/plugins/plugin.spec.ts
@@ -3,6 +3,7 @@ import { createNodes } from './plugin';
 import { TempFs } from 'nx/src/internal-testing-utils/temp-fs';
 
 jest.mock('@nx/devkit/internal', () => ({
+  ...jest.requireActual('@nx/devkit/internal'),
   loadConfigFile: jest.fn().mockImplementation(() => {
     return Promise.resolve({
       buildDir: '../dist/my-app/.nuxt',
diff --git a/tools/workspace-plugin/src/generators/create-nodes-plugin/__snapshots__/generator.spec.ts.snap b/tools/workspace-plugin/src/generators/create-nodes-plugin/__snapshots__/generator.spec.ts.snap
index e31ebbd6..4a789e2c 100644
--- a/tools/workspace-plugin/src/generators/create-nodes-plugin/__snapshots__/generator.spec.ts.snap
+++ b/tools/workspace-plugin/src/generators/create-nodes-plugin/__snapshots__/generator.spec.ts.snap
@@ -250,11 +250,15 @@ function mockEslintConfig(config: any) {
 `;
 
 exports[`create-nodes-plugin/generator generator should run successfully 3`] = `
-"import { formatFiles, getProjects, Tree } from '@nx/devkit';
+"import {
+  formatFiles,
+  getProjects,
+  Tree,
+  replaceProjectConfigurationsWithPlugin,
+} from '@nx/devkit';
 import { createNodes } from '../../plugins/plugin';
 
 import { createProjectRootMappingsFromProjectConfigurations } from 'nx/src/project-graph/utils/find-project-for-path';
-import { replaceProjectConfigurationsWithPlugin } from '@nx/devkit/src/utils/replace-project-configuration-with-plugin';
 
 export default async function update(tree: Tree) {
   const proj = Object.fromEntries(getProjects(tree).entries());

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally tcjz-7eua

Apply fix locally with your editor ↗   View interactive diff ↗



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

FrozenPandaz added a commit that referenced this pull request May 5, 2026
)

## Current Behavior

The 23.0.0-beta.6 `@nx/devkit` deep-import migration (#35541) catches
non-named-import shapes (default / namespace / side-effect / `require()`
/ dynamic `import()` / `jest.mock`-style calls) by running a regex sweep
over the file:

```ts
const FALLBACK_RE = /(['"])@nx\/devkit\/src\/[^'"\n]+?\1/g;
updated = updated.replace(
  FALLBACK_RE,
  (_match, quote: string) => `${quote}${INTERNAL_SPECIFIER}${quote}`
);
```

That sweep matches **any** `'@nx/devkit/src/...'` literal anywhere in
the file, regardless of context. As a result the migration mangled:

- **Test fixtures inside template literals** — including the migration's
own `update-deep-imports.spec.ts`. Examples observed in the wild:
`packages/devkit/src/migrations/update-23-0-0/update-deep-imports.spec.ts`,
`packages/expo/src/utils/expo-project-detection.spec.ts`,
`packages/nuxt/src/plugins/plugin.spec.ts`,
`packages/react-native/src/utils/react-native-project-detection.spec.ts`,
etc. ([#35565](#35565))
- **`typeof import('@nx/devkit/src/...')` type queries** — e.g.
`libs/shared/npm/src/lib/local-nx-utils/parse-target-string.ts` in
nrwl/nx-console, where the type now claims `@nx/devkit/internal` while
the runtime `importPath` next to it is built dynamically and still
points at `src/...`.
([nrwl/nx-console#3131](nrwl/nx-console#3131))
- **Deep-import paths in comments**, doc strings, and arbitrary
string-literal arguments to unrelated functions.

## Expected Behavior

The migration only rewrites deep-import paths that are *actually* import
sites. Everything else (template strings, type queries, comments,
unrelated calls) is left alone.

This is implemented by replacing the regex sweep with a TypeScript-AST
visitor that only rewrites the string-literal argument of
`CallExpression` nodes whose callee is one of:

- `require` (identifier)
- the dynamic-`import` keyword
- `jest.mock` / `jest.unmock` / `jest.doMock` / `jest.dontMock` /
`jest.requireActual` / `jest.requireMock`
- `vi.mock` / `vi.unmock` / `vi.doMock` / `vi.dontMock` /
`vi.requireActual` / `vi.requireMock` / `vi.importActual` /
`vi.importMock`

Type queries (`ImportTypeNode`), template literals, and comments are all
naturally untouched because they are not `CallExpression` nodes — no
allowlist needed. Quote style is preserved per literal.

The named-import bucketing pass and the duplicate-collapse pass are
unchanged.

### Tests

10 new unit tests:

- 5 in a new `non-runtime string literals` block guarding template
literals, `typeof import(...)` type queries, block comments, line
comments, and unrelated call expressions.
- 5 in a new `mock helper calls` block covering `jest.mock`,
`jest.requireActual`, `vi.mock`, `vi.importActual`, and a paired
`import` + `jest.mock` + `jest.requireActual` combination.

All 39 unit tests pass; `nx build devkit` is clean.

## Related Issue(s)

Follow-up to #35541. Workspaces that have already merged the bad
rewrites need to revert those files by hand — there's no general way to
undo the over-rewrites without losing the legitimate ones.

---------

Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
Co-authored-by: FrozenPandaz <FrozenPandaz@users.noreply.github.com>
@FrozenPandaz FrozenPandaz changed the title chore(repo): update nx to 23.0.0-beta.6 chore(repo): update nx to 23.0.0-beta.7 May 5, 2026
@FrozenPandaz FrozenPandaz enabled auto-merge (squash) May 5, 2026 19:02
@FrozenPandaz FrozenPandaz merged commit ff0eec2 into master May 5, 2026
27 checks passed
@FrozenPandaz FrozenPandaz deleted the upnx branch May 5, 2026 19:14
@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 May 11, 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