vue-bulma-accordion icon indicating copy to clipboard operation
vue-bulma-accordion copied to clipboard

v0.4 does not work or SSR

Open frandiox opened this issue 5 years ago • 9 comments

Hi! First of all, thank you for this library. I've been using it for long before 0.4 and was working perfectly. I just updated to 0.4.7 and I'm getting "document is not defined" around this line: https://github.com/Lunrtick/vue-bulma-accordion/blob/master/dist/vue-bulma-accordion.umd.js#L283

I'm using this on Vuepress, which renders everything at build time using Node and obviously document object is not defined. A possible solution is wrapping bulma-accordion in <ClientOnly> so it doesn't render at build time, but then all the text shown in the accordion cannot be indexed by search engines. I guess this is related to Rollup but there should be a way to avoid calling undefined objects in SSR 🤔

Thanks!

frandiox avatar Mar 18 '19 14:03 frandiox

Hey frandiox, glad to hear that it's been helpful for you!

I have looked into this - it does seem like a problem with Rollup, as you suggested. The pertinent issue is here. There is a possible workaround, as documented here, though that seems pretty irritating to have to deal with.

I will give it some thought, and see if I can figure an alternative out - if you have any suggestions, I'd also love to hear them!

Lunrtick avatar Mar 22 '19 15:03 Lunrtick

I had this issue too with nuxt. Made me downgrade to 0.3.3 which works great too! 🍻

HugoHeneault avatar Oct 04 '19 09:10 HugoHeneault

I also downgraded to 0.3.3, luckily we don't need the new features of 0.4.x yet. Any ETA when this issue could be resolved?

drbarto avatar Jan 08 '20 11:01 drbarto

i had this issue too, did you using nuxt?,

i resolve this by adding BulmaAccordion and BulmaAccordionItem into plugins,

~plugins/vue-global-components.js file:

import {
    BulmaAccordion,
    BulmaAccordionItem
  } from 'vue-bulma-accordion'

Vue.component('BulmaAccordion', BulmaAccordion);  
Vue.component('BulmaAccordionItem', BulmaAccordionItem);"

and add it in nuxt.config.js

plugins:[
    {
      src: '~plugins/vue-global-component.js',
      ssr: false
    }]

last dont forget to remove local import at spesific file

jemjov41 avatar Jan 20 '20 08:01 jemjov41

I've just published 0.5, which changes some implementation details and uses parcel instead of rollup. I don't use SSR much, but from my testing it seems to have fixed the problem (occasionally I saw an HTML mismatch during testing, couldn't figure out why).

I would love to get a hand from someone who uses SSR!

Lunrtick avatar Feb 06 '20 19:02 Lunrtick

Hey there! So I'm using SSR and with 0.5.2 it's working fine. Awesome! 👏

With nuxt when you first load a page containing the accordion and initial-open-items it's opening on page ready (I think).

But when you navigate to the page with nuxt/vue rendering client side the items don't open.

Is it SSR related or shall I open another issue?

HugoHeneault avatar Feb 07 '20 08:02 HugoHeneault

I also have the error:

The client-side rendered virtual DOM tree is not matching server-rendered content. 

What coud I do to help you?

HugoHeneault avatar Feb 07 '20 08:02 HugoHeneault

With nuxt when you first load a page containing the accordion and initial-open-items it's opening on page ready (I think).

But when you navigate to the page with nuxt/vue rendering client side the items don't open.

Is it SSR related or shall I open another issue?

It seems to be SSR related, so let's keep it here (:

Lunrtick avatar Feb 08 '20 11:02 Lunrtick

I also have the error:

The client-side rendered virtual DOM tree is not matching server-rendered content. 

What coud I do to help you?

When I got that error, I compared the client rendered html character by character with the SSR'd html - they seem to be identical. My intuition says I'm doing something that SSR doesn't like (maybe the inline styles or something), but I don't have any experience with it, so I don't know.

This Stackeroverflow answer may help with debugging the issue - I will look into it locally as well.

Lunrtick avatar Feb 08 '20 11:02 Lunrtick