prazdevs / pinia-plugin-persistedstate

💾 Configurable persistence and rehydration of Pinia stores.
https://prazdevs.github.io/pinia-plugin-persistedstate/
MIT License
2.16k stars 122 forks source link

Does not work properly in vue3 #305

Closed hubeishuaige closed 3 months ago

hubeishuaige commented 6 months ago

Describe the bug

It is normal in vue3 local project development, but after executing the yarn build packaging and publishing command, this plug-in does not work, and there is no error prompt, as if there is no one

Reproduction

It is normal in vue3 local project development, but after executing the yarn build packaging and publishing command, this plug-in does not work, and there is no error prompt, as if there is no one

System Info

{
  "name": "robot-bee-admin",
  "version": "0.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@element-plus/icons-vue": "^2.3.1",
    "axios": "^1.7.2",
    "element-plus": "^2.7.3",
    "nprogress": "^0.2.0",
    "pinia": "^2.1.7",
    "pinia-plugin-persistedstate": "^3.2.1",
    "sass": "^1.77.2",
    "vue": "^3.4.21",
    "vue-router": "^4.3.0"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^5.0.4",
    "vite": "^5.2.8"
  }
}

Used Package Manager

yarn

Validations

prazdevs commented 6 months ago

Hi please provide a proper reproduction so I can help :)

hubeishuaige commented 6 months ago

image image

Dherlou commented 5 months ago

Same problem here. Simple (new) VueJS v3 app (Vite) using pinia for managing the stores (which just contain a few strings in my case), which works fine by itself.

Then I tried to add this extension and followed the getting started guide, but no matter what I configure, this extension acts as if it isn't there. Nothing is persisted/loaded, hooks are not called and no debug info is logged. When I try to $persist()/$hydrate() manually, the app tells me that those functions are not defined.

My guess is that the extension is not loaded at all (at least in the way the documentation shows)?

Nemure231 commented 4 months ago

can confirm, in newest vue3 vite, i only use simple code inside pinia like this, { persist: { storage: localStorage, paths: ['use-my-fetch-crane'] } } i have lot of ref() state in pinia, and its only saved empty object like this in localStorage:

Capture
VladiStep commented 4 months ago

can confirm, in newest vue3 vite, i only use simple code inside pinia like this, { persist: { storage: localStorage, paths: ['use-my-fetch-crane'] } } i have lot of ref() state in pinia, and its only saved empty object like this in localStorage:

Capture

Same Nevermind, it's just JSON.stringify() can't serialize Map.