Skip to content

Not SSR Friendly #9

@kevintruby

Description

@kevintruby

Hi there! Not sure if you're still maintaining this library.

Recently used this to create a dynamic image gallery, and everything was working fine until I reached the point of wiring up vue-server-renderer. When compiling, Node.js outputs the following error:

ReferenceError: window is not defined
    at Object.<anonymous> (/...omitted_for_brevity.../node_modules/vue-l-carousel
/dist/main.js:1:216)

From what I can see in the source code, you're relying on access to the window object directly at the beginning of the script tag for the Carousel component -- haven't checked the CarouselItem component.

It would be great if this library could follow the conventions outlined by Vue SSR documentation for isomorphic/universal code. Looks like the safest place to execute component code that relies on platform-specific variables like window and document would be in the mounted() lifecycle hook.

I don't know if that would be significant to refactor or not; I've only taken a cursory look at the source code so far.

If I can find some spare time, I might try to fork and fix, then submit a PR, but figured it would be worth raising for now. At the very least, wanted this issue noted in case anyone else runs into an issue integrating with SSR as well.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions