Skip to content

Commit

Permalink
fix: dedupe pinia (#2821)
Browse files Browse the repository at this point in the history
  • Loading branch information
posva authored Nov 3, 2024
1 parent 40828b6 commit 90d8eb9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
isNuxtMajorVersion,
addImports,
createResolver,
resolveModule,
addImportsDir,
} from '@nuxt/kit'
import type { NuxtModule } from '@nuxt/schema'
Expand Down Expand Up @@ -63,15 +62,11 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
// Transpile runtime
nuxt.options.build.transpile.push(resolve(runtimeDir))

// This alias broke in Nuxt 3 so only add it in Nuxt 2
if (isNuxtMajorVersion(2, nuxt)) {
// Make sure we use the mjs build for pinia
nuxt.options.alias.pinia =
nuxt.options.alias.pinia ||
// FIXME: remove this deprecated call. Ensure it works in Nuxt 2 to 3
resolveModule('pinia/dist/pinia.mjs', {
paths: [nuxt.options.rootDir, import.meta.url],
})
// avoids having multiple copies of pinia
nuxt.options.vite.optimizeDeps ??= {}
nuxt.options.vite.optimizeDeps.exclude ??= []
if (!nuxt.options.vite.optimizeDeps.exclude.includes('pinia')) {
nuxt.options.vite.optimizeDeps.exclude.push('pinia')
}

nuxt.hook('prepare:types', ({ references }) => {
Expand Down

0 comments on commit 90d8eb9

Please sign in to comment.