Skip to content

Commit

Permalink
perf: install plugins only once
Browse files Browse the repository at this point in the history
it was done once per request and was a noop after first install
  • Loading branch information
posva committed Nov 11, 2021
1 parent 50fa329 commit 1b8e363
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/nuxt/src/templates/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit 1b8e363

Please sign in to comment.