]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
perf: install plugins only once
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 11 Nov 2021 08:32:05 +0000 (09:32 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 11 Nov 2021 08:32:05 +0000 (09:32 +0100)
it was done once per request and was a noop after first install

packages/nuxt/src/templates/plugin.ts

index df6717d043c817d972d12fd098490c066da05961..c523f9b79ae45e0d7a40ae5374970fe14e1c47ce 100644 (file)
@@ -2,14 +2,14 @@ import { install, isVue2, Vue2 } from 'vue-demi'
 import { createPinia, setActivePinia, PiniaVuePlugin } from 'pinia'
 import type { Plugin } from '@nuxt/types'
 
-const PiniaNuxtPlugin: Plugin = (context, inject) => {
-  if (isVue2) {
-    install()
-    // TODO: workaround that should probably be removed in the future
-    const Vue = 'default' in Vue2 ? Vue2.default : Vue2
-    Vue.use(PiniaVuePlugin)
-  }
+if (isVue2) {
+  install()
+  // TODO: workaround that should probably be removed in the future
+  const Vue = 'default' in Vue2 ? Vue2.default : Vue2
+  Vue.use(PiniaVuePlugin)
+}
 
+const PiniaNuxtPlugin: Plugin = (context, inject) => {
   const pinia = createPinia()
   if (isVue2) {
     // simulate new Vue({ pinia })