]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(nuxt): make `$nuxt` non enumerable
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 16 Aug 2021 12:54:00 +0000 (14:54 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 16 Aug 2021 12:54:00 +0000 (14:54 +0200)
Fix #574

nuxt/plugin.js

index 4f96e787d480e719948d994aafa5ed807a62c52b..2ab7645c7de2d01184237aefe066bf44a5844918 100644 (file)
@@ -20,8 +20,10 @@ const myPlugin = (context, inject) => {
   setActivePinia(pinia)
 
   // we bypass warnings
-  // @ts-expect-error
-  pinia._p.push(() => ({ $nuxt: context }))
+  pinia._p.push(({ store }) => {
+    // non enumerable to avoid it being serialized or displayed in devtools
+    Object.defineProperty(store, '$nuxt', { value: context })
+  })
 
   if (process.server) {
     context.beforeNuxtRender(({ nuxtState }) => {