chore(repo): update nx to 23.0.0-beta.11#3131
Conversation
|
View your CI Pipeline Execution ↗ for commit 78eca78
☁️ Nx Cloud last updated this comment at |
) ## 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>
Co-authored-by: FrozenPandaz <FrozenPandaz@users.noreply.github.com>
| "jest": "30.3.0", | ||
| "jest-environment-jsdom": "30.0.5", | ||
| "jest-environment-node": "29.7.0", |
There was a problem hiding this comment.
Version mismatch between Jest and its environment packages. jest is updated to 30.3.0 while jest-environment-node remains at 29.7.0 (major version behind). This will likely cause compatibility issues since Jest 30.x expects environment packages to be on version 30.x.
"jest": "30.3.0",
"jest-environment-jsdom": "30.3.0",
"jest-environment-node": "30.3.0",Both jest-environment-jsdom should also be updated from 30.0.5 to 30.3.0 to match the Jest core version, and jest-environment-node needs to be updated from 29.7.0 to 30.3.0.
| "jest": "30.3.0", | |
| "jest-environment-jsdom": "30.0.5", | |
| "jest-environment-node": "29.7.0", | |
| "jest": "30.3.0", | |
| "jest-environment-jsdom": "30.3.0", | |
| "jest-environment-node": "30.3.0", | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this comment.
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 update the parseTargetString helper to fix TypeScript compilation failures caused by the @nx/devkit 23.0.0-beta.11 upgrade, which removed the ./src/executors/parse-target-string subpath export and dropped the top-level src/ directory from the published package. These changes resolve all three failing tasks (nx-mcp:build:production, shared-npm:typecheck, vscode:build:ci) by pointing both the runtime import and the TypeScript type annotation at the correct, still-exported locations.
Tip
✅ We verified this fix by re-running shared-npm:typecheck, nx-mcp:build:production.
diff --git a/libs/shared/npm/src/lib/local-nx-utils/parse-target-string.ts b/libs/shared/npm/src/lib/local-nx-utils/parse-target-string.ts
index 79f3066..26937b3 100644
--- a/libs/shared/npm/src/lib/local-nx-utils/parse-target-string.ts
+++ b/libs/shared/npm/src/lib/local-nx-utils/parse-target-string.ts
@@ -14,10 +14,8 @@ export async function parseTargetString(
if (!devkitPath) {
throw 'local @nx/devkit dependency not found';
}
- const importPath = join(devkitPath, 'src/executors/parse-target-string');
+ const importPath = join(devkitPath, 'dist/src/executors/parse-target-string');
const { parseTargetString } =
- await importWorkspaceDependency<
- typeof import('@nx/devkit/src/executors/parse-target-string')
- >(importPath);
+ await importWorkspaceDependency<typeof import('@nx/devkit')>(importPath);
return parseTargetString(targetString, projectGraph);
}
Or Apply changes locally with:
npx nx-cloud apply-locally otbg-ENCj
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
…export Nx 23 added an exports field to @nx/devkit/package.json that blocks the @nx/devkit/src/executors/parse-target-string subpath. Use the top-level export instead, which has been available since Nx 16.
Updating Nx from 23.0.0-beta.4 to 23.0.0-beta.11