-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
isOldIE throws 'window is not defined' in non-browser environments #272
Comments
Guys any update on this. do we have any PR for this. This should be simple one line change. |
@michael-ciniawsky friendly ping |
@indolent-developer Describe your use case please and provide |
@michael-ciniawsky i have reference this in library where we see issues. And regardless of that the code is not correct. Dont you agreee? The window checks are different in code else where. |
@indolent-developer Then please provide more info about this issues :). Let's say I don't disagree but the checks seem to work and unless there isn't a confirmed bug within the scope of this loader there is less reason to change anything |
tl;dr: The check does not work and that doesn't matter. As per the OP, you can't check for existence of a global variable by seeing if it's truthy (which is what the check does). Just checking However, it's irrelevant whether this check is fixed, because style-loader relies on the existence of a michael-ciniawsky's comments in the PR are why this issue should be closed:
For SSR specifically:
|
Thanks for the replies peeps. What about the use case where a bundle includes both DOM dependent modules, and non-DOM dependent modules? I have a "component library" that has a bunch of react modules being compiled, but also a config file that needs to be accessed by DefinePlugin in another module. In my case, fixing the check would allow me to require just the single file I need. Can we implement this fix? |
Don't use style-loader in devel Webpack config because it always references `window` which breaks Node.js pre-rendering of React components. webpack-contrib/style-loader#272
Modify Webpack to build and expose package as a library. Most importantly, we specify the Webpack config's `library` and `libraryTarget` fields to export the code as as UMD library. We also set Webpack `output.globalObject` to `this` so that the code can run in both Node.js for pre-rendering and in the browser. Reconcile some differences between the prod and development Webpack config. I'm not really sure why these differences were in place, but some of them were causing problems. Don't use style-loader in devel Webpack config because it always references `window` which breaks Node.js pre-rendering of React components. [1] Allow the babel-loader to run on pixel-art-react for when this is imported as a library. If we just excluded it from running on any `node_modules` it would not process the React code inside `pixel-art-react` when `pixel-art-react` is installed into the importer's `node_modules` folder. [1]: webpack-contrib/style-loader#272
I'm using React server-side rendering in React.NET and compiling my app with
webpack
+style-loader
+etc.isOldIE
assumeswindow
as a variable exists and can be falsy. The correct way to check for its existence would betypeof
like inlib/urls.js
.The text was updated successfully, but these errors were encountered: