Open lestephane opened 4 years ago
Seems like this is a yarn
feature.
https://github.com/yarnpkg/yarn/issues/5347
https://github.com/yarnpkg/yarn/issues/5347#issuecomment-463038189
Have you checked node_modules
to see if the peer dependencies are in fact installed? I could reproduce this issue, but the dependencies showed up in node_modules
as desired.
Have you checked
node_modules
to see if the peer dependencies are in fact installed?
Yup, they are installed.
yarnpkg/yarn#5347 (comment)
If I depend on @aws-cdk/aws-ecs which in turns depends on 22(!) peer dependencies, and my code could break if I forget to add an explicit dependency on all of them, are these 22 peer dependencies not, in fact, actual transitive dependencies, and should not be declared as peer dependencies but 'real' dependencies in @aws-cdk/aws-ecs?
https://github.com/yarnpkg/yarn/issues/5347#issuecomment-386288470
Because they are dependencies of your dependencies, it throws a warning because it needs to be hoisted by the package manager. If you tried it with npm, it would do the same hoisting, but without printing the most of the warnings.
So no, you won't need to explicitly add the peer dependencies.
(Welcome to JS lol)
Ok, but say, I import @aws-cdk/aws-dynamodb@1.59.0
but I don't make use of KMS encryption at all in conjunction with Dynamodb, and therefore has unmet peer dependency "@aws-cdk/aws-kms@1.59.0"
is of no relevance to me, since all it's saying is "IF you use KMS in combination with DynamoDB, then it must be this aws-kms module version".
I don't care, since I'm not using KMS.
This, to me, points to the real problem, that peerDependencies have not been declared as optional (when applicable).
Looking at package.json
for @aws-cdk/aws-dynamodb
"dependencies": {
...
"@aws-cdk/aws-kms": "1.60.0",
...
},
....
"peerDependencies": {
...
"@aws-cdk/aws-kms": "1.60.0",
...
},
Should there not be as well:
"peerDependenciesMeta": {
"@aws-cdk/aws-kms": {
"optional": true
}
}
I think this would remove the warning and make the intent clear, as long as only optional peer dependencies are marked optional of course.
This will be solved in 2.0 of the AWS CDK. We are planning to release the entire CDK as a single module (aws-cdk-lib
) so hopefully this hell will go away.
Here you can find more information about monolithic packaging.
We will consider annotating our deps with peerDependenciesMeta.optional
for 1.x in the meantime to reduce the grief.
Any update on adding the optional annotation? I architect across many applications for a large enterprise and our migration to 2.0 will not be immediate. In the meantime, as an example, a very small project I'm involved with is getting 62 warnings of this type. When warnings become spam, developers ignore warnings. I believe we can all agree, that is not a desirable outcome.
I come from the java world and try to reduce my dependencies to the exact set that I need. So I'm not an npm / yarn expert, but the verbosity I'm having to deal with in the context of installing aws-cdk modules is a bit intimidating.
When I do a fresh yarn install, I get lots of peer dependencies warnings. What am I supposed to do about it? If there is nothing I can do about it, how can I avoid seeing these warnings (and indeed why are they warnings at all)?
I think this is more of a generic npm / yarn question, but still, I want to know how people deal with this in the context of the aws-cdk, where each imported module has many peer dependencies, causing many such warnings. I don't like those, they keep reminding me that I'm either doing something wrong, or that yarn is using the wrong level of logging...
Input appreciated, thanks.
package.json
fragmentyarn install
output fragment