44import {
55 defineNuxtModule ,
66 addPlugin ,
7- isNuxt2 ,
7+ isNuxtMajorVersion ,
88 addImports ,
99 createResolver ,
1010 resolveModule ,
@@ -54,7 +54,7 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
5454 nuxt . options . features &&
5555 // ts
5656 options . disableVuex &&
57- isNuxt2 ( )
57+ isNuxtMajorVersion ( 2 , nuxt )
5858 ) {
5959 // @ts -expect-error: no `store` feature flag in nuxt v3
6060 nuxt . options . features . store = false
@@ -63,13 +63,16 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
6363 // Transpile runtime
6464 nuxt . options . build . transpile . push ( resolve ( runtimeDir ) )
6565
66- // Make sure we use the mjs build for pinia
67- nuxt . options . alias . pinia =
68- nuxt . options . alias . pinia ||
69- // FIXME: remove this deprecated call. Ensure it works in Nuxt 2 to 3
70- resolveModule ( 'pinia/dist/pinia.mjs' , {
71- paths : [ nuxt . options . rootDir , import . meta. url ] ,
72- } )
66+ // This alias broke in Nuxt 3 so only add it in Nuxt 2
67+ if ( isNuxtMajorVersion ( 2 , nuxt ) ) {
68+ // Make sure we use the mjs build for pinia
69+ nuxt . options . alias . pinia =
70+ nuxt . options . alias . pinia ||
71+ // FIXME: remove this deprecated call. Ensure it works in Nuxt 2 to 3
72+ resolveModule ( 'pinia/dist/pinia.mjs' , {
73+ paths : [ nuxt . options . rootDir , import . meta. url ] ,
74+ } )
75+ }
7376
7477 nuxt . hook ( 'prepare:types' , ( { references } ) => {
7578 references . push ( { types : '@pinia/nuxt' } )
@@ -78,7 +81,7 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
7881 // Add runtime plugin before the router plugin
7982 // https://github.com/nuxt/framework/issues/9130
8083 nuxt . hook ( 'modules:done' , ( ) => {
81- if ( isNuxt2 ( ) ) {
84+ if ( isNuxtMajorVersion ( 2 , nuxt ) ) {
8285 addPlugin ( resolve ( runtimeDir , 'plugin.vue2' ) )
8386 } else {
8487 addPlugin ( resolve ( runtimeDir , 'plugin.vue3' ) )
0 commit comments