-
feat(core): add support for '...' as a spread token when merging target config (#34285)
发布于
2026-04-24 18:55:43 +00:00 When merging project configurations (e.g., from plugins,
project.json,
target defaults innx.json), array and object properties are
completely replaced by the new value. There is no way to extend or merge
with the base value.For example, if a plugin infers:
{ "targets": { "build": { "inputs": ["default", "{projectRoot}/**/*"] } } }And
nx.jsonhas target defaults:{ "targetDefaults": { "build": { "inputs": ["production"] } } }The result would be
["production"]— completely replacing the inferred
inputs rather than combining them.This PR adds support for
"..."as a spread token when merging
configurations. Users can now control how arrays and objects are merged
by specifying where the base value should be inserted.Array spread:
{ "inputs": ["production", "...", "{workspaceRoot}/.eslintrc.json"] }Results in:
["production", "default", "{projectRoot}/**/*", "{workspaceRoot}/.eslintrc.json"]Object spread:
{ "options": { "env": { "NEW_VAR": "value", "...": true, "OVERRIDE_VAR": "overridden" } } }Spreads the base object's properties at the position of
"...", with
keys defined after the spread taking precedence.This works in:
- Top-level target properties (
inputs,outputs,dependsOn) - Target
optionsand nested option objects (one layer deep) - Target
configurationsand their options (one layer deep) - Both
project.jsonmerging andnx.jsontarget defaults
Fixes #
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>下载附件
- Top-level target properties (