Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check against server fails on Deno #199

Closed
bebraw opened this issue Sep 9, 2020 · 2 comments · Fixed by #201
Closed

Check against server fails on Deno #199

bebraw opened this issue Sep 9, 2020 · 2 comments · Fixed by #201
Labels
bug Something isn't working

Comments

@bebraw
Copy link
Contributor

bebraw commented Sep 9, 2020

Bug report

Stitches fails to run through Deno.

Describe the bug

I am currently trying to use stitches through Deno (1.3.3). I found out that there's an assumption in SSR that doesn't hold in the environment and subsequently running stitches through Deno crashes.

To Reproduce

Make sure to install Deno first (available through brew for example). Then, run the sample script below:

import css from "https://dev.jspm.io/@stitches/css@9.0.0-alpha.8";

const c = css.createCss({ prefix: "", tokens: {}, breakpoints: {}, utils: {} });

It will crash with error: Uncaught TypeError: Cannot read property 'documentElement' of undefined.

Expected behavior

It should not crash.

Proposed solution

The issue occurs because the code checks for the environment based on the existence of window. In Node environment it's undefined but in Deno it's defined as it maintains partial compatibility with the object.

To solve, there should be a more robust check against the environment that works reliably for both Node and Deno. Maybe a simple way would be to check against the Deno object as that's guaranteed to exist for Deno but it shouldn't exist in the browser.

System information

  • OS: macOS
  • Deno 1.3.3.
@peduarte peduarte added the bug Something isn't working label Sep 9, 2020
@peduarte
Copy link
Contributor

peduarte commented Sep 9, 2020

@bebraw Thanks for raising. We'll work on it. Seems like you know what's up, so feel free to create a PR if you wish 🚀

@bebraw
Copy link
Contributor Author

bebraw commented Sep 9, 2020

@peduarte Sure, I'll add a check in a bit. 👍

bebraw added a commit to bebraw/stitches that referenced this issue Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants