Open Odas0R opened 1 year ago
Here's a possible fix:
import type { Component, JSX } from "solid-js";
import { isServer } from "solid-js/web";
import type { TransitionProps } from "solid-transition-group";
import { Transition as SolidTransition } from "solid-transition-group";
export const Transition: Component<
TransitionProps & {
children: JSX.Element;
}
> = (props) => {
if (isServer) {
return props.children;
}
return <SolidTransition {...props} />;
};
Interesting
I've removed all export conditions from dependencies and decided to just rely on isServer
exported by solid, but as it turns out, isServer
is different when imported in a module and locally. This means that on the server there are two different versions of solid running which can be very bad.
Not sure if that's an issue of @astrojs/solid-js
or the wrangler
.
Huh! wierd :')
So that's why it was throwing an error, and why it works locally on the fix above.
I tried to give it a look but found no answer to why... But it could be any one of the two, since the cloudflare adapter wraps everything on the _worker.js
, when acessing SSR Pages, it might conflict there.
Maybe an additional check is needed to see if it is on a Worker environemnt (a.k.a server environment)?
Maybe an additional check is needed to see if it is on a Worker environemnt (a.k.a server environment)?
Nobody's gonna do that unfortunately. isServer
is the most idiomatic check we have.
Besides it would only hide the issue (like your Transition wrapper does) which is that the bundler doesn't respect export conditions in upstream dependencies. You have a client version of solid running on the server.
This is something worth bringing up with the astro team instead.
I'll open an issue there to see if we can arrange a fix. Thanks for debugging this!
@Odas0R any updates on this? can you link the issue?
I'm so sorry @thetarnav, it has been crazy days since the past month. I did not create the issue and forgot completely to notice you!
I'll probably only be available in the summer :')
If till now no one looked into this, I'll try to debug more.
Here's the reproduction url:
https://github.com/Odas0R/solid-group-transition-bug
Everything you need to do is on the URL to throw the error. I'm using
wrangler
cli which emulates a worker environment. Code also breaks in production.This is the code that breaks:
On the astro page:
The error: