Should Vue.use(VueCompositionAPI) be called explicitly when using Pinia with Vue 2 - seems that explicit call is required with Webpack but not with Vite #1339
Unanswered
realmerx
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying out Pinia (excellent library btw :) ) with Vue 2 using https://github.com/piniajs/example-vue-2-vite as example (with Vite). I notice that there is no direct call to Vue.use(VueCompositionAPI) and example works - it seems if you do Vue.use(PiniaVuePlugin) the Composition API also automatically becomes available.
Trying it out with Webpack it seems that explicit call to Vue.use(VueCompositionAPI) is required and just calling Vue.use(PiniaVuePlugin) is not enough - reactivity in store does not work even when only using Options API.
Debugging this it seems that Pinia dependency vue-demi calls Vue.use(VueCompositionApi) itself :
https://github.com/vuejs/pinia/blob/v2/packages/pinia/src/vue2-plugin.ts#L1
and
https://github.com/vueuse/vue-demi/blob/main/lib/v2/index.mjs#L7
but I am not sure why it is only called with Vite
All in all it seems that Pinia with Vue 2 example (https://github.com/piniajs/example-vue-2-vite) would be clearer if it would call Vue.use(VueCompositionAPI) explicitly (tried calling it expliciitly with Vite as well and everything still seems to work)
Beta Was this translation helpful? Give feedback.
All reactions