-
fix(core): do not drop target defaults in 23.0.0 array migration (#35711)
发布于
2026-05-16 13:14:31 +00:00 Current Behavior
The
convert-target-defaults-to-arraymigration (Nx 23) converts the
legacy
record-shapetargetDefaultsinnx.jsonto the new array shape.It declared a
projectGraphparameter 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
breakingbuild(lostdependsOn) andtest(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.下载附件
- The entry point takes an honest