Nx
Enterprise
Nx
fix(core): do not drop target defaults in 23.0.0 array migration (#35711) ## Current Behavior The `convert-target-defaults-to-array` migration (Nx 23) converts the legacy record-shape `targetDefaults` in `nx.json` to the new array shape. It declared a `projectGraph` parameter and classified each record key against the graph, dropping any key whose target name / executor wasn't found in the workspace. But the migration runner always invokes migrations as `fn(tree, {})` — the second argument is an empty object, never a project graph. `{}` is truthy, so it was treated as a real (but empty) graph. Every non-glob key then matched neither a target name nor an executor, and the migration dropped it. As a result, upgrading to Nx 23 deletes every named `targetDefaults` entry (`build`, `test`, `lint`, …) and keeps only glob entries — silently breaking `build` (lost `dependsOn`) and `test` (lost env/options) across the workspace. ## Expected Behavior The migration is a pure shape conversion and never drops entries: - The entry point takes an honest `(tree)` signature — it no longer pretends to receive a project graph it is never given. - Every legacy key produces at least one array entry. Globs and plain (non-`:`) keys become `{ target: key }`; `:` keys are disambiguated by the project graph (`target`, `executor`, or both), falling back to the syntactic heuristic (`:` → executor) when the graph has no signal. - The project graph is built internally, and only when a `:`-style key actually needs disambiguating. - The pure conversion is exposed as `convertTargetDefaultsRecordToArray` so the disambiguation logic is unit-testable with injected graphs, without standing up a workspace or the migration runner. ## Related Issue(s) N/A — caught while upgrading the Nx repo itself to `23.0.0-beta.13`.
nx affected --targets=lint,test,build,e2e,e2e-ci,format-native,lint-native,gradle:build-ci,vale,run
Sign in / Sign up
Open main menu
Fetching task details...