S
SolidJS7mo ago
Dido

SyntaxError: The requested module 'solid-js/web' does not provide an export named 'classList'

I am getting this error when using the solid-slider library in my code during SSR. I am using Solid 1.8.3 and solid-slider 1.3.15. Does anyone have any pointers what could cause this?
3 Replies
Vincent Udén
Vincent Udén7mo ago
I've had some problems with similar issues but I'm no expert so forgive me if I'm wrong. The problem is that solid-slider expects to be rendered only on client and thus uses the classList export from solid-js/web either directly or in one of it's dependencies. classList isn't exported from the server version of solid-js/web much like template or some other constructs due to the SSR not being done in a browser, but rather in node. For me the fix has been to import some of my components as client only. This means they don't get SSRed but still allows me to use them. To do this, use
import { unstable_clientOnly } from "solid-start";

const Plot = unstable_clientOnly(() => import("../components/Plot"));
import { unstable_clientOnly } from "solid-start";

const Plot = unstable_clientOnly(() => import("../components/Plot"));
Where you replace the import with your component that needs to be client only. This hasn't worked in all cases for me. I have no good understanding of when it works and when it doesn't. I've asked about it here before and got no answer. Also I realise this assumes you're using solid-start which you might not be. If you aren't, I wish you the best of luck on finding another solution
Dido
Dido7mo ago
Hi @Vincent Udén thanks for sharing your experiences. I'm indeed not using Solid Start so this particular solution probably won't work for me. However, this
The problem is that solid-slider expects to be rendered only on client and thus uses the classList export from solid-js/web either directly or in one of it's dependencies.
confirms what I was suspecting. It seemed odd to me that the rollup build of that package is only done without passing any SSR options (so it defaults to DOM). We currently evaluating whether we can replace or fork this package. Thanks for your hints.
Vincent Udén
Vincent Udén7mo ago
Yeah it's been a suprisingly common problem for me, components breaking in ssr. I'm not clever enough to figure out the solutions if there are any goods ones. It's a little bit demotivating tbh, but at least there are usually alternative libraries which do work
Want results from more Discord servers?
Add your server
More Posts