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

fix(addStyles): allow window && document to not exist (isOldIE) #273

Closed
wants to merge 1 commit into from
Closed

Conversation

JoshuaKGoldberg
Copy link

Fixes #272.

What kind of change does this PR introduce?
Bugfix

Did you add tests for your changes?
No. Do you test this type of behavior?

Summary
Uses typeof checks so the function doesn't crash if window or document don't exist.

Does this PR introduce a breaking change?
No.

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Nov 11, 2017

Duplicate of #250

style-loader requires a DOM and doesn't officially support SSR. Does 'SSR' work with your proposed fix ? Please provide more info about your setup && concrete use case. If the current behaviour just prevents some 'SSR-ish' use case from working we can/will accept this change (#250)

@michael-ciniawsky michael-ciniawsky changed the title Allowed window, document to not exist in isOldIE fix(addStyles): allow window && document to not exist (isOldIE) Nov 11, 2017
@michael-ciniawsky michael-ciniawsky added this to the 0.18.3 milestone Nov 11, 2017
@JoshuaKGoldberg
Copy link
Author

Ha, didn't see the dup. At least mine doesn't have unnecessary parenthesis...? 😄

Does 'SS' work with your proposed fix?

No, style-loader still crashes when it tries to use document.createElement. But I don't see any reason not to allow this PR in: it doesn't hurt any behavior.

setup && concrete use case

The project is compiled with Webpack into a single file that's use for client-side rendering (traditional use case). I'd like to take that file and dump it onto the server. This is the only blocker.

As a workaround, I forked our Webpack config file and replaced style-loader references with ExtractTextPlugin & similar to stub out the CSS... but it would be much cleaner to just use style-loader natively.

@michael-ciniawsky
Copy link
Member

kk, please use an proper alternative instead e.g isomorphic-style-loader. style-loader solely adds CSS via <style> to the DOM

@indolent-developer
Copy link

indolent-developer commented Nov 16, 2017

i don't understand why are we just blatantly removing a PR. People are talking time to fix things which are breaking build which were working fine. This code line is wrong.
return window && document && document.all && !window.atob; whatever env we are running this.

The type check for window should be done better and that is what people are tying to do.
No where in code window checks are done in the way done here.
https://github.com/webpack-contrib/style-loader/search?utf8=%E2%9C%93&q=window&type=

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Nov 17, 2017

@indolent-developer I asked for a reproduction where these checks aren't actually working && which isn't used for SSR and got no failing example until now. I'm more then open to merge this if it is really needed

@JoshuaKGoldberg JoshuaKGoldberg deleted the patch-1 branch November 17, 2017 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

isOldIE throws 'window is not defined' in non-browser environments
3 participants