From: Eduardo San Martin Morote Date: Thu, 11 Nov 2021 08:32:05 +0000 (+0100) Subject: perf: install plugins only once X-Git-Tag: @pinia/nuxt@0.1.5~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1b8e36355d52eb0934364bf622846e3bceced590;p=thirdparty%2Fvuejs%2Fpinia.git perf: install plugins only once it was done once per request and was a noop after first install --- diff --git a/packages/nuxt/src/templates/plugin.ts b/packages/nuxt/src/templates/plugin.ts index df6717d0..c523f9b7 100644 --- a/packages/nuxt/src/templates/plugin.ts +++ b/packages/nuxt/src/templates/plugin.ts @@ -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 })