feature(envs) - support new "extends" field in env.jsonc #8896
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
"extends"
field in your env.jsoncextends
should be the package name of the env you want to extend.Merge strategy
patterns
In the
patterns
object, each key will be overridden by the child as is (no internal merge of the arrays).If you have a key in the parent that doesn't exist on the child it will be taken as is from the parent.
policy
For each type of dependency (dev/peer/runtime), each object will be taken from the child by the name.
so if you have a dependency on peers in the parent like this:
and in the child
The final result will be the child, as they have the same value for name, and the same type (peers)
If an entry with a given name exists only in one of the env.jsonc, it will be taken as is.
So the final array will have entries from both the child and the parent.
In case you want to just remove some dep from the parent you can use
"-"
as the version value.This will not remove the dependency from the component, rather then will remove it from the env policy.
(in most cases it will, in that case, change the behavior so bit will be using the auto-resolve algorithm to resolve the version of a dependency rather than remove it (unless you don't use that dependency)
This way you can also use it in order move something from one type to another.
see the following example:
and you want to move lodash to be a dev dependency
you are using
"-"
to remove it from runtime, and add it again in dev.Full example:
Let's assume we have 3 envs one extends another as below.
And we configure env-level3 for our component.
Final merged config: