Open doubtx opened 2 years ago
Glider will probably only work on the client side. I’m mobile but look at the docs for “browser” and you should be able to limit it’s execution to just the browser.
Hey, @nickreese I cant inject any check for third part lib to validate if it is running on browser or not
This is a common issue when we try to share the same code between the server and the client.
Ideally, we only need to import the library in client build. However, there is no way to apply conditions to import statements.
You can try to guard the code and configure treeshake.moduleSideEffects
option in rollup. Maybe it will trim the module when it is not used.
Hello, I am using external Carousel library called 'glider-js' In Glider JS code there is a check if window is defined and if not - it falls back to 'this':
However, when request is served on server side (via "npm run dev") or during the build process, this is also not defined so I am getting error:
I have already tried to play with 'hydrate-client' and tried to set rollup context to 'this'. Seems issue is not really related to rollup, as
runs ok
You can reproduce the issue as follows:
PS. It all works perfectly on Svelte Kit + Vite, so maybe Rollup can be the reason, but then I dont understand how exactly