Update: Splide is now in Version 3 and (since the update) React Splide appears to work well with Gatsby (tested on V4) without any additional confi...
For further actions, you may consider blocking this person and/or reporting abuse
Awesome article! I wonder do you know what is the root cause of this? I am currently struggling with this error with an internal third party library which I can easily contribute to. Is something messed up with the build output of that third party library (maybe tweak the Webpack / Rollup config on the libraries side)?
Ah I think Gatsby does not work well with UMD library output. I've changed the third party library to use CommonJS and now I don't need any workarounds.
Here is my rollup config:
The libraries tsconfig.json:
and my build command:
tsc -p . && rollup -c
Sorry @brunnerlivio I missed your comment. That's a great find, I wasn't sure of the root cause myself but your insight is really useful. Thank you.
Worte an article shedding a light on this here:
dev.to/brunnerlivio/use-stencil-wi...
Hi Jamie, thank you so much for this article!
It's the only one that helped me get Splidejs (great tool) and Gatsby working on the site I was building.
Just one suggestion, with the new SSR Gatsby functionality set to true (and so active) now it's better to update the if statement inside the onCreateWebpackConfig to "if (stage === "build-html" || stage === "develop-html")" so that you don't receive any error during development phase (gatsby develop). At least I had to do it. Maybe you could update the article with this info, it could help someone else.
Thank you so much for your help
Sorry for the delayed response Marco! I've had some time away from this site for a bit as I've been busy with day job. Yeah absolutely I'll get this updated and thank you for sharing.
Hi Jamie, thanks for the tutorial!
But i follow the step above, and it seems the errors still appear.
Do you have any idea?
Oh that's not good (and slightly awkward 😬) which of the errors are you still getting? I'm presuming you mean:
Let me know. I'm happy to have a look if you want share the code with me, maybe DM me on Twitter(@jamiebradley234)?
Here's my code pastebin.com/m4cB3Rec
Btw, I can't send the dm to your Twitter.
Thanks, can you send me your twitter handler please and I'll try reaching out to you over Twitter. I've got some questions but I don't want to spam the thread 😂
Sure, twitter.com/difaananda40
Thanks for going through this with me on Twitter! For everyone else's reference the change was to update object in the rules array from:
to
I have updated the post accordingly!
Hi Jamie, I followed these steps and the build ran fine. But getting this error on the rendered HTML:
[SPLIDE] Track or list was not found.
j @ splide.esm.js:953
2react-dom.production.min.js:216 TypeError: Cannot read property 'length' of undefined
at Object.get length as length
at i.get (splide.esm.js:1838)
at Object.get edgeIndex as edgeIndex
at Object.handler (splide.esm.js:2755)
at splide.esm.js:139
at Array.forEach ()
at Object.emit (splide.esm.js:137)
at i.r.emit (splide.esm.js:1703)
at i.r.refresh (splide.esm.js:1772)
at m.value (Splide.js:208)
Hi, if you're still having issues I suggest you try reverting the changes made and importing node-self before your splider import.
The
self is not defined
error relates toself
not being implemented in NodeJs - the above fixes that issue and the result should be a fully working SSR rendered splider. (At least that is the case in my Gridsome project).Cheers!
Thanks @animald , appreciate the input!
Sorry for the delay Zubair, interesting as I've not seen this error before. I don't suppose this is related to Marco's comment regarding SSR during dev? I'm only asking with you saying that the build worked fine. I'm reading this as it worked during build phase but not dev phase. Thanks!
Thanks, I was looking exactly for a solution for that problem!