Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is @vue/composition-api a dependency? #7

Closed
NickBolles opened this issue Aug 21, 2020 · 7 comments
Closed

Why is @vue/composition-api a dependency? #7

NickBolles opened this issue Aug 21, 2020 · 7 comments

Comments

@NickBolles
Copy link

Shouldn't it be a peer dependency? I think that this is messing with my app after updating @vue/apollo-composable from 4.0 alpha 9 to alpha 10, which adds vue-demi

@NickBolles
Copy link
Author

I actually can't tell if it's this module, which is causing 2 copies of @Vue/Composition-api, or if it's the upgrade in @vue/composition-api itself. Either way, I don't think that vue-demi should have @vue/composition-api as a dependency.

@NickBolles
Copy link
Author

NickBolles commented Aug 21, 2020

update: this does indeed look like it's causing my issues. Here's my packages, before - with @vue/apollo-composable@ alpha10 and after downgrade - @vue/apollo-composable@ alpha9. This is the same version of @vue/composition-api

Before downgrade

client> yarn why @vue/composition-api
├─ @nuxtjs/composition-api@npm:0.12.2
│  └─ @vue/composition-api@npm:1.0.0-beta.10 (via npm:^1.0.0-beta.10)
│
├─ @nuxtjs/composition-api@npm:0.12.2 [0c378]
│  └─ @vue/composition-api@npm:1.0.0-beta.10 [c4e01] (via npm:^1.0.0-beta.10 [c4e01])
│
└─ vue-demi@npm:0.2.0
   └─ @vue/composition-api@npm:1.0.0-beta.10 [c4e01] (via npm:^1.0.0-beta.10 [c4e01])
client> yarn why vue-demi
├─ @vue/apollo-composable@npm:4.0.0-alpha.10
│  └─ vue-demi@npm:0.2.0 (via npm:latest)
│
└─ @vue/apollo-composable@npm:4.0.0-alpha.10 [68254]
   └─ vue-demi@npm:0.2.0 (via npm:latest)

After downgrade to @vue/apollo-composable

graphql> yarn why @vue/composition-api
├─ @nuxtjs/composition-api@npm:0.12.2
│  └─ @vue/composition-api@npm:1.0.0-beta.10 (via npm:^1.0.0-beta.10)
│
└─ @nuxtjs/composition-api@npm:0.12.2 [0c378]
   └─ @vue/composition-api@npm:1.0.0-beta.10 [c4e01] (via npm:^1.0.0-beta.10 [c4e01])
graphql> yarn why @vue/apollo-composable
└─ @App/Client@workspace:packages/client
   └─ @vue/apollo-composable@npm:4.0.0-alpha.9 [0c378] (via npm:4.0.0-alpha.9 [0c378])

The errors I would get are, Maximum call stack exceeded. It was an infinite loop in nextTick, and I tracked it down, in my case, to being called by the first nuxt module that initialized and tried to use a composition API. In my case that was @nuxtjs/auth-next

I'm still unclear why this was an actual issue, since I would expect yarn to dedupe the package and only have one copy. but it really appears that this is the issue to me.

@antfu
Copy link
Member

antfu commented Aug 22, 2020

Could you share a minimal reproduce repo? Thanks.

@vue/composition-api becomes a dependency because the philosophy of vue-demi is trying to abstract the lower layer of details to exposing the APIs for 2 & 3 as the same as possible.

@Demivan
Copy link
Contributor

Demivan commented Aug 23, 2020

@NickBolles I had similar issue with yarn and found out that yarn does not always dedupe on update. Removing lock file and installing packages again fixed dedupe issues for me.

But that is exactly what peer dependencies are for, so package does not install dependency itself but uses dependency from parent package.

composition-api could even be optional peer dependency so users that use vue@3 don't get warning that composition-api is not installed. Right now users that use vue@3 will have composition-api installed even though it is not needed.

Same deal with Vue. It should be in peer dependencies. With range that allows vue@2 and vue@3. I'm using yarn@2 and it is stricter about checking dependencies. It does not allow package to import dependency that is not in dependencies or peer dependencies. I will create issue about yarn@2 with reproduce repo later.

@NickBolles
Copy link
Author

NickBolles commented Aug 23, 2020

Thanks for the confirmation @Demivan I'm also using Yarn 2

@antfu honestly I tried, but in my case it requires setting up Nuxt, Nuxt auth, composition API and Apollo. It takes a while. But I did do the investigation. To find the root cause and we have at least one other confirmation.

Our argument is that dependency is wrong. It happens to also have been causing a functional issue for me, and probably will for others. Either way, optional peer dependency is the right thing to do.

If you really need a repro I can spend some time later today putting it together.

@antfu
Copy link
Member

antfu commented Aug 23, 2020

Sure, I will change it to peerDeps. Thanks

@antfu
Copy link
Member

antfu commented Aug 23, 2020

Done with v0.3.0. Check it out :)

@antfu antfu closed this as completed Aug 23, 2020
renatodeleao added a commit to renatodeleao/v-click-outside that referenced this issue Jul 19, 2022
using vue-demi requires that vue2.6 projects install "@vue/composition-api", always! Even though I believe is the norm in 2.6.x projects but still kind of bummer to get an install error. vue-demi lists @vue/composition-api as optional peer dependency because it would otherwise install it for vue2.7 and vue3.x projects. We could list @vue/composition-api as dependency as well to overcome the install issue, but we're not using anything on this package so why complicate things?

1. I've removed vue-demi altogether, replaced the only thing we've use isVue3 with simply version regexp
1. the swap-vue.js from vuelidate allow us to keep the isomorphic testing to ensure it works everything

Related issues:
vueuse/vue-demi#67
vueuse/vue-demi#7
renatodeleao added a commit to renatodeleao/v-click-outside that referenced this issue Jul 19, 2022
using vue-demi requires that vue2.6 projects install "@vue/composition-api", always! Even though I believe is the norm in 2.6.x projects but still kind of bummer to get an install error. vue-demi lists @vue/composition-api as optional peer dependency because it would otherwise install it for vue2.7 and vue3.x projects. We could list @vue/composition-api as dependency as well to overcome the install issue, but we're not using anything on this package so why complicate things?

1. I've removed vue-demi altogether, replaced the only thing we've use isVue3 with simply version regexp
1. the swap-vue.js from vuelidate allow us to keep the isomorphic testing to ensure it works everything

Related issues:
vueuse/vue-demi#67
vueuse/vue-demi#7
renatodeleao added a commit to renatodeleao/v-click-outside that referenced this issue Jul 19, 2022
using vue-demi requires that vue2.6 projects install "@vue/composition-api", always! Even though I believe is the norm in 2.6.x projects but still kind of bummer to get an install error. vue-demi lists @vue/composition-api as optional peer dependency because it would otherwise install it for vue2.7 and vue3.x projects. We could list @vue/composition-api as dependency as well to overcome the install issue, but we're not using anything on this package so why complicate things?

1. I've removed vue-demi altogether, replaced the only thing we've use isVue3 with simply version regexp
1. the swap-vue.js from vuelidate allow us to keep the isomorphic testing to ensure it works everything

Related issues:
vueuse/vue-demi#67
vueuse/vue-demi#7
renatodeleao added a commit to renatodeleao/v-click-outside that referenced this issue Jul 19, 2022
using vue-demi requires that vue2.6 projects install "@vue/composition-api", always! Even though I believe is the norm in 2.6.x projects but still kind of bummer to get an install error. vue-demi lists @vue/composition-api as optional peer dependency because it would otherwise install it for vue2.7 and vue3.x projects. We could list @vue/composition-api as dependency as well to overcome the install issue, but we're not using anything on this package so why complicate things?

1. I've removed vue-demi altogether, replaced the only thing we've use isVue3 with simply version regexp
1. the swap-vue.js from vuelidate allow us to keep the isomorphic testing to ensure it works everything

Related issues:
vueuse/vue-demi#67
vueuse/vue-demi#7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants