yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.44k stars 1.11k forks source link

[Bug] peerDepedencies inside dependendencies. #617

Closed chumager closed 4 years ago

chumager commented 4 years ago

Describe the bug I use bootstrap-vue in my vuejs project... that module use portal-vue who has a peer dependencie with vue. As yarn v1 has flat installation there is no problem because I depend on vue (vue project). But with berry I can't access vue from portal-vue and can't compile it.

To Reproduce install global @vue/cli to get vue command

vue create -d -m yarn bootstrap-vue-test cd bootstrap-vue-test yarn policies set-version v2 yarn set version from sources yarn install yarn -D add vue-cli-plugin-pnp bootstrap bootstrap-vue rm -fr node_modules

Modify src/main.js to:

import Vue from 'vue'
import App from './App.vue'

import BootstrapVue from "bootstrap-vue";
Vue.use(BootstrapVue);

Vue.config.productionTip = false

new Vue({
  render: h => h(App),
}).$mount('#app')

yarn build

Environment if relevant (please complete the following information):

Additional context

with yarn install:

➤ YN0000: ┌ Resolution step ➤ YN0002: │ bootstrap-vue@npm:2.1.0 doesn't provide jquery@1.9.1 - 3 requested by bootstrap@npm:4.4.1 ➤ YN0002: │ bootstrap-vue@npm:2.1.0 doesn't provide vue@^2.5.18 requested by portal-vue@npm:2.1.6 ➤ YN0002: │ bootstrap-vue-test@workspace:. doesn't provide jquery@1.9.1 - 3 requested by bootstrap@npm:4.4.1 ➤ YN0002: │ bootstrap-vue-test@workspace:. doesn't provide popper.js@^1.16.0 requested by bootstrap@npm:4.4.1 ➤ YN0000: └ Completed in 0.2s ➤ YN0000: ┌ Fetch step ➤ YN0000: └ Completed in 0.58s ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed in 1.67s ➤ YN0000: Done with warnings in 2.49s

chumager commented 4 years ago

If I change the .pnp.js file and add the portal-vue dependencies it works

from:

      ["portal-vue", [
        ["virtual:c69cc5f8cb29a57fd55819b15648f5384f96692ffa0cf6fbad26ab4afce8f3da66298f7b8b0caf36ade5c51ea2875c0671a9cdc264bfb89622240dd242d24a41#npm:2.1.6", {
          "packageLocation": "./.yarn/virtual/portal-vue-virtual-2c5965cea0/5/.yarn/berry/cache/portal-vue-npm-2.1.6-0a1e7fdd38-1.zip/node_modules/portal-vue/",
          "packageDependencies": [
            ["portal-vue", "virtual:c69cc5f8cb29a57fd55819b15648f5384f96692ffa0cf6fbad26ab4afce8f3da66298f7b8b0caf36ade5c51ea2875c0671a9cdc264bfb89622240dd242d24a41#npm:2.1.6"],
            ["vue", null]
          ],
          "packagePeers": [
            "vue"
          ],
          "linkType": "HARD"
        }],
        ["virtual:da162e11bac5fc73582728521417dafd226e1d98a52fa4bd76b8e8e644e05aa0393e4959fe9f8d963ac514d3dc009aaf5e82119857ce0d5ad5c9bfa39421cd58#npm:2.1.6", {
          "packageLocation": "./.yarn/virtual/portal-vue-virtual-58d12ba4e0/5/.yarn/berry/cache/portal-vue-npm-2.1.6-0a1e7fdd38-1.zip/node_modules/portal-vue/",
          "packageDependencies": [
            ["portal-vue", "virtual:da162e11bac5fc73582728521417dafd226e1d98a52fa4bd76b8e8e644e05aa0393e4959fe9f8d963ac514d3dc009aaf5e82119857ce0d5ad5c9bfa39421cd58#npm:2.1.6"],
            ["vue", "npm:2.6.10"]
          ],
          "packagePeers": [
            "vue"
          ],
          "linkType": "HARD"
        }]
      ]],

to:

      ["portal-vue", [
        ["virtual:c69cc5f8cb29a57fd55819b15648f5384f96692ffa0cf6fbad26ab4afce8f3da66298f7b8b0caf36ade5c51ea2875c0671a9cdc264bfb89622240dd242d24a41#npm:2.1.6", {
          "packageLocation": "./.yarn/virtual/portal-vue-virtual-2c5965cea0/5/.yarn/berry/cache/portal-vue-npm-2.1.6-0a1e7fdd38-1.zip/node_modules/portal-vue/",
          "packageDependencies": [
            ["portal-vue", "virtual:c69cc5f8cb29a57fd55819b15648f5384f96692ffa0cf6fbad26ab4afce8f3da66298f7b8b0caf36ade5c51ea2875c0671a9cdc264bfb89622240dd242d24a41#npm:2.1.6"],
            ["vue", "npm:2.6.10"]
          ],
          "packagePeers": [
            "vue"
          ],
          "linkType": "HARD"
        }],
        ["virtual:da162e11bac5fc73582728521417dafd226e1d98a52fa4bd76b8e8e644e05aa0393e4959fe9f8d963ac514d3dc009aaf5e82119857ce0d5ad5c9bfa39421cd58#npm:2.1.6", {
          "packageLocation": "./.yarn/virtual/portal-vue-virtual-58d12ba4e0/5/.yarn/berry/cache/portal-vue-npm-2.1.6-0a1e7fdd38-1.zip/node_modules/portal-vue/",
          "packageDependencies": [
            ["portal-vue", "virtual:da162e11bac5fc73582728521417dafd226e1d98a52fa4bd76b8e8e644e05aa0393e4959fe9f8d963ac514d3dc009aaf5e82119857ce0d5ad5c9bfa39421cd58#npm:2.1.6"],
            ["vue", "npm:2.6.10"]
          ],
          "packagePeers": [
            "vue"
          ],
          "linkType": "HARD"
        }]
      ]],

it worked fine, at least it compiles...

I copied from the portal-vue definition because I added portal-vue, maybe you already have some API or command to resolve this but in the documentation I didn't find it.

arcanis commented 4 years ago

If portal-vue has a peer dependency on vue, then bootstrap-vue has one as well and should list it.

I copied from the portal-vue definition because I added portal-vue, maybe you already have some API or command to resolve this but in the documentation I didn't find it.

The packageExtensions setting is what you're looking for.

chumager commented 4 years ago

As you said, portal-vue depends on Vue but bootstrap-vue don't, because it's already compiled, portal-vue instead, imports vue, they should include it because bootstrap-vue needs vue yo satisfy portal-vue peer dependency.

Thanks for the configuration tip.

arcanis commented 4 years ago

I'm going to close this issue since I don't think we can do anything more on our side 🙂