Closed nathanchase closed 1 week ago
My stores are auto importing on compatibilityVersion: 4
just fine without me changing anything, all I did after enabling compatibilityVersion: 4
was move my directories (including the store
directory) into app/
then ran nuxt dev
and everything was happy
Edit: typo'd my stores
directory, should indeed read as stores
not store
My stores are auto importing on
compatibilityVersion: 4
just fine without me changing anything, all I did after enablingcompatibilityVersion: 4
was move my directories (including thestore
directory) intoapp/
then rannuxt dev
and everything was happy
Hmm... I wonder if it's a difference in your store dir name? I use stores
, where it sounds like you use store
.
I found that all my stores auto-importing failed if I used the new /app
dir structure and moved my stores
dir into /app
, unless I explicitly added the storesDir
config to point to the correct location.
Well, now that I've created the issue, it doesn't appear to be happening anymore, no matter what I name my store directory. I guess this is a false alarm - or potentially something changed between Nuxt 3.12 patch versions that fixed it.
What problem is this solving
Just thought I'd mention that if you are using Pinia with Nuxt ^3.12 and have
compatibilityVersion: 4
set (to simulate Nuxt 4.0 functionality), then the use of auto-imports will require an update to the stores path to the new Nuxt 4 directory structure.It's easy enough to update your
nuxt.config.ts
to:but perhaps this is something that the Pinia Nuxt module can detect itself and adjust the
storesDirs
path accordingly?Proposed solution
For added developer experience, add some update to the Pinia Nuxt module that will detect Nuxt ^4.0, or
compatibilityVersion: 4
, and update its defaultstoresDirs
configuration accordingly to the new app structure where/app
is the default root directory for your Nuxt app.Describe alternatives you've considered
Manual setting of the config.