Skip to content

Commit

Permalink
fix(nuxt): ensure pinia plugin is added before router
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Nov 18, 2022
1 parent 8f51e68 commit 3e4e63c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
references.push({ types: '@pinia/nuxt' })
})

// Add runtime plugin
if (isNuxt2()) {
addPlugin(resolver.resolve('./runtime/plugin.vue2'))
} else {
addPlugin(resolver.resolve('./runtime/plugin.vue3'))
}
// Add runtime plugin before the router plugin
// https://github.com/nuxt/framework/issues/9130
nuxt.hook('modules:done', () => {
if (isNuxt2()) {
addPlugin(resolver.resolve('./runtime/plugin.vue2'))
} else {
addPlugin(resolver.resolve('./runtime/plugin.vue3'))
}
})

// Add auto imports
const composables = resolver.resolve('./runtime/composables')
Expand Down

0 comments on commit 3e4e63c

Please sign in to comment.