vueuse: peerDependencies on vue missing for @vueuse/core and @vueuse/shared

Describe the bug

When requesting @vueuse/core with Yarn, it complains about a missing dependency on vue due to using vue-demi:

➤ YN0002: │ @vueuse/core@npm:9.12.0 doesn't provide vue (p0865e), requested by vue-demi
➤ YN0002: │ @vueuse/shared@npm:9.12.0 doesn't provide vue (p9bab8), requested by vue-demi
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code

This is due to the removal of the vue peerDependency and peerDependenciesMeta in this commit: https://github.com/vueuse/vueuse/commit/1b258ac8dbf02eb455af07b1bc52e447484f6f90

Reproduction

https://github.com/wopian/vueuse-repro (run yarn after cloning this repo to see above message)

System Info

Binaries:
  Node: 19.6.0 - C:\Program Files\nodejs\node.EXE
  Yarn: 3.4.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm: 8.17.0 - C:\Program Files\nodejs\npm.CMD

Used Package Manager

yarn

Validations

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 17 (2 by maintainers)

Most upvoted comments

According to vue-demi’s README, plugins/libraries using vue-demi need to also provide the peerDependencies for the versions of vue and @vue/composition-api they want to support:

https://github.com/vueuse/vue-demi#usage image

That would be the recommended fix for this issue.

Otherwise, for now, users of vueuse can provide packageExtensions in the .yarnrc.yml to address the warning coming from yarn, with something such as the following (which mimics the required fix anyway):

packageExtensions:
  #"@vueuse/<package>@<version>:
  #e.g.:
  "@vueuse/core@10.4.1":
    peerDependencies:
      vue: ^3.0.0-0 || ^2.6.0

Parent packages need to declare the non-optional peer dependencies of packages in their dependencies as peer or optional peer dependencies. It would be optional peer dependencies with */any version for @vueuse/* as they do not import vue

https://yarnpkg.com/advanced/error-codes#yn0002---missing_peer_dependency

I.e for each @vueuse/* package that depends on vue-demi, they need these lines (excluding the composition package as its optional in vue-demi): https://github.com/vueuse/vueuse/commit/1b258ac8dbf02eb455af07b1bc52e447484f6f90#diff-0b810c38f3c138a3d5e44854edefd5eb966617ca84e62f06511f60acc40546c7L41-L48

I’m using @vueuse/core and I had to fix the missing peerDependencies in multiple @vueuse packages because @vueuse/core depends on @vueuse/shared which also has a dependency to vue-demi.

Here are my changes to .yarnrc.yaml to whom it may concern:

packageExtensions:
  "@vueuse/core@*":
    peerDependencies:
      vue: ^3.0.0-0 || ^2.6.0
  "@vueuse/shared@*":
    peerDependencies:
      vue: ^3.0.0-0 || ^2.6.0

Not stale