Closed moltar closed 2 years ago
Parallax is a frontend effect. How you will use it on the server side?
Yes, it is used on the front-end, but build tools don't know this. Most SSR build tools expect the component to work in all environments. There are workarounds though, so it's not a show stopper. Just would be easier if it did comply with the ecosystem.
E.g. I am specifically talking about Nuxt in this case. If I import
this in one of the Vue pages, it will fail compilation.
I'm not familiar with Nuxt and Vue, but recently I worked on the React project with server-side rendering also. And in situations, when there was different methods for server and client side, I'm just included it in this way:
Based on this project https://github.com/kriasoft/react-starter-kit
I'm not using Jarallax for server side. If you want, feel free to make PR with a fix.
Anyone have an update this? Facing similar issues with Nuxt SSR.
I also faced the same issues.
added Next.js example https://github.com/nk-o/jarallax/tree/master/examples/next
In this example used dynamic import to prevent errors in SSR:
If you have more workarounds, I will be glad to look at them.
Issue description:
The use of
lite-ready
assumes that we are in a client-side environment.But during server-side rendering (SSR), the DOM is not available and compilation errors out.
There are workarounds. And I think maybe this should be directed towards
lite-ready
, rather than this module. But maybe there is another, module similar tolite-ready
that correctly detects whether we are in client side or not.There is a
can-use-dom
module that detects if DOM can be used.https://github.com/akiran/can-use-dom
Version used:
Latest.
Code to reproduce the issue (HTML blocks + JavaScript initialization)
Just requiring it in a Vue component while rendering server side.
Thank you!