silencesys / silentbox

A lightbox inspired Vue.js component.
https://silentbox.rocek.dev
MIT License
296 stars 51 forks source link

silentbox is not compatible with SSR #14

Closed ArthurHoaro closed 5 years ago

ArthurHoaro commented 5 years ago

I can't make silentbox work with server side rendering enabled.

Whenever I try to import vue-silentbox I get a 500 error with:

ReferenceError: document is not defined

It looks like I can't import it only in client mode. Also, I tried to import the single component directly, and use it with vue-no-ssr plugin without any luck.

silencesys commented 5 years ago

Hello,

thank you for reporting, the issue should be fixed now. In case the error remains, let me know.

ArthurHoaro commented 5 years ago

Thanks for the real quick fix and release, however it doesn't seem to fix the issue for me.

Here is the full stacktrace if it can help:

ReferenceError: document is not defined
    at <path>/node_modules/vue-silentbox/dist/vue-silentbox.umd.js:227:16
    at <path>/node_modules/vue-silentbox/dist/vue-silentbox.umd.js:2:68
    at Object. (<path>/node_modules/vue-silentbox/dist/vue-silentbox.umd.js:5:2)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at r (<path>/node_modules/vue-server-renderer/build.dev.js:9300:16)
    at Object.vue-silentbox (webpack:/external "vue-silentbox":1:0)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at Module../src/main.js (app.js:9268:72)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at Module../src/entry-server.js (app.js:9160:63)
    at __webpack_require__ (webpack/bootstrap:25:0)
silencesys commented 5 years ago

I have tried to update the plugin a bit, but I was not able to reproduce the error you had (I've got different ones related to SSR). Could you please check if the issue was fixed also for you? Otherwise I might need to know your Nuxt and probably also ESlint configs, so I can try to reproduce the error.