gruntjs / gruntjs/grunt

allow deep-merging of options?

Open
#1,180 9 comments 1 reaction 0 assignees View on GitHub
needs discussion
Dominant language
JavaScript
Stars
12.2k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Some task authors have expressed a desire for `this.options()` to (recursively) deep merge task options. Right now, options are shallow merged (one level deep).

(Currently, target-level config options override task-level config options, which override built-in task options. Nobody is asking for this to change, yay)

_Why aren't options deep merged? Because options are atomic. While individual options must be merged into a single object, their values should be left unchanged._

To better understand this, we must understand what an option is. An option is a single value used to configure a task. Tasks can be configured with zero or more options. Thus, the merged options object may contain, as its properties, zero or more options, each with a corresponding value.

When one thinks about options in this way, the idea of deep merging all options seems a bit heavy handed. So I'll propose an alternative, although I'm not sure what it should look like yet.

What if task authors could specify, inside the task where they specify the built-in default values, a per-option setting that enables deep merging _for that option_? The setting could be a number representing the max depth. And it would default to `0` or `false` for a shallow merge.

Thoughts?

Contributor guide

Open the contributing guide

Research direction

The issue discusses changing how this.options() merges task configuration, but it names no files, tests, or implementation entry point. First inspect the existing options-merging behavior and the task configuration API, then determine whether per-option merge depth has an agreed design. Done requires a documented, accepted API and tests covering the proposed merge semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.