fix(material): ng-add should always install matching CDK version #18076
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.
Currently ng-add for Angular Material determines the version name
of the CDK and Angular Material by looking for
@angular/cdk/package.json
and
@angular/material/package.json
in the node modules.This is incorrect because other installed packages could rely on older
CDK versions being installed. In those cases, we don't want to add that
transitively installed CDK version to the
package.json
file. Instead,we always want to add the CDK version that matches Angular Material.
We can do this by just relying on the version placeholder we use in
other locations too.
Also in the issue ticket (#18020) it was mentioned that we might want
to warn if a lower CDK version is transitively installed. This seems unnecessary
since we explicitly add a project-scoped dependency on the CDK and transitive
CDK dependencies are scoped to the packages that require it. Also I think it would be
out of scope for
ng add
to handle potential scenarios of non-matching CDK installations.Fixes #18020