-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
fix(addStyles): use typeof
to check for existence of window
&& document
objects
#250
Conversation
FYI this is in addition to #177 which curiously is not enough 😦 |
typeof
to check for existence of window
&& document
objects
@bherila In which exact enviroment do you use the loader (JSDOM) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems sane to me. Maybe it's better to push the check to one place, though, and use it across the codebase, though?
@bherila can your provide use case, where your need this check? best - create test repo |
@michael-ciniawsky It was in my attempt to get https://github.com/barbar/vortigern working with bootstrap-loader (bootstrap 4). I have been attempting to get bootstrap 4 rendering with isomorphic-style-loader, and ideally have the bootstrap 4 critical path CSS analyzed and rendered server-side. As you can see from the vortigern site, there are a lot of packages being assembled together here :-\ Also, I would have shared the repo in which this reproduces, however it's for a client and I am not sure I can publish all the code on Github. I can try to make a minimal repro-repo if it would be helpful somehow. It's basically the stock vortigern + a few source files + bootstrap-loader. |
any update on merging this issue. |
@veeramarni Could you describe your 'use case' ? Why/Where are the current checks insufficient?
|
@michael-ciniawsky I still see those errors when running with SSR. In my case, we use webpack to create npm packages and we use these packages in an application where we get |
SSR isn't officially supported, this loader only works in the browser or browser-like env like JSDOM.
Would this PR resolve your issue ? |
I will give a try with this PR and let you know. |
What kind of change does this PR introduce?
Fixes the following error which occurs during Webpack build by adding the check via the
typeof
operator.Did you add tests for your changes?
n/a
If relevant, did you update the README?
n/a
Summary
Of note, other places in this file use the
typeof
operator, but curiously it is not done here.Does this PR introduce a breaking change?
No
Other information
n/a, it's a one-liner 😄