Skip to content

Commit

Permalink
refactor: use optimizeDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Nov 3, 2024
1 parent 49a7039 commit c4dd627
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
// Transpile runtime
nuxt.options.build.transpile.push(resolve(runtimeDir))

// dedupe pinia only if not building for SSR
// https://github.com/vitejs/vite-plugin-vue/blob/main/packages/plugin-vue/src/index.ts#L221
if (!nuxt.options.vite?.build?.ssr) {
nuxt.options.vite.resolve ??= {}
nuxt.options.vite.resolve.dedupe ??= []
if (!nuxt.options.vite.resolve.dedupe.includes('pinia')) {
nuxt.options.vite.resolve.dedupe.push('pinia')
}
// 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 c4dd627

Please sign in to comment.