lukejacksonn / oceanwind

Compiles tailwind shorthand into css at runtime. Succeeded by Twind.
https://twind.dev
264 stars 12 forks source link

Adds test for server side rendering #16

Closed lukejacksonn closed 3 years ago

lukejacksonn commented 3 years ago

This is an extension of #7 where most of the work was done by @bebraw 🙇 some things that I took the liberty of changing from that branch included:

What still remains is:

This seems to work pretty nicely for me.. I wonder, is this sufficient for general SSR now?

bebraw commented 3 years ago

This seems to work pretty nicely for me.. I wonder, is this sufficient for general SSR now?

That's a good question. I've worked against my forked version and apart from the issues I opened (separate from SSR), it simply works. 😎

lukejacksonn commented 3 years ago

Awesome! Thanks for the review. I feel this should also just work™️ but it would be great if you could confirm. I will address your other comments now.

bebraw commented 3 years ago

Awesome! Thanks for the review. I feel this should also just work™️ but it would be great if you could confirm. I will address your other comments now.

There's one thing you could add now that I think of it. See https://github.com/bebraw/oceanwind/blob/personal/util/otion.mjs#L71 . That's a fix against Deno for Otion. Otherwise SSR won't work through Deno.

bebraw commented 3 years ago

The issue is that Deno exposes window and I recall their original check used the window object to tell if it's run in a browser or not. That needs an extra check in Deno environment. It should also avoid the process.env problem if done right.

lukejacksonn commented 3 years ago

Ok I have copied over the contents of the file you linked to into this branch. When I tried running it in the browser I got the process is undefined error. So I updated the checks to look like this:

const isDeno = typeof window !== 'undefined' && window.Deno;
const isBrowser = isDeno ? false : typeof window !== 'undefined';
const isDev = isDeno || isBrowser ? false : process.env.NODE_ENV !== 'production';

Note the new isDeno || isBrowser check. Does that make sense to you?

bebraw commented 3 years ago

@lukejacksonn Yeah, that isDeno || isBrowser bit makes sense.

The three lines is starting to feel like some utility to test and extract but there's no need to do that now.

We should try to get this code upstream at some point. 😄

lukejacksonn commented 3 years ago

Yeh I agree. Will have to ask @kripod to take a look and see what he thinks!

lukejacksonn commented 3 years ago

I think this is good to go now. Might merge then publish!

lukejacksonn commented 3 years ago

Ok, got there in the end! Thanks for all your help @bebraw and @jovidecroock 🙇

I will take a look at the other issues now, starting with #10 so that you can start linking from here rather than a fork.

kripod commented 3 years ago

Great job, looks good to me! Thank you for asking me to take a look 😊

bebraw commented 3 years ago

Awesome, thanks a lot. 👍