-
Notifications
You must be signed in to change notification settings - Fork 754
Remove window variable from ExecJS environment #615
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
Conversation
Looks like running into the same error as on #611 |
334c5c8
to
feb0dbb
Compare
Replacing window with global enables the removal of the window object shim in ExecJS render
This can cause issues when using 3rd party libraries that do a presence check on window to determine if browser functions are available
feb0dbb
to
82c2072
Compare
Removed the update to React |
I think this is Ok, but we need to document the change so that people who currently depend on window (using it as the global namespace) know how to upgrade. I checked coffeescript, it looks like it compiles to something compatible: @test = false to (function() {
this.test = false
}).call(this) (I thought it might use |
Indeed, I'm attempting to apply this update to our app to see if its even feasible / sensible to make this change |
How did it go applying this to your app? |
I hope it went ok :P But I agree, making server render pretend to be a browser env only makes it worse down the line. |
🚢 in |
Not actually sure how to fix the errors we get after upgrading to
The components we use do not reference The CHANGELOG mentions manually adding |
@dbackeus Do those errors come from server rendering? Do you have a server-rendering manifest (some file that requires all the components for server rendering)? If so, you can add it to that file, for example: //= require components
// polyfill `window` variable for server rendering environments:
var window = this If that doesn't help, can you share the lines of code that reference |
FYI I had the same e.g. prerender_polyfill.js // polyfill for prerendering. must be set before requiring react
var window = this; components.js //= require prerender_polyfill
//= require react_app |
Since |
Fixes #614
Defining window on the server can cause major issues when using 3rd party libraries that perform type of checks on the window variable to detect the presence of a browser environment.
A common check for presence of the browser is:
This PR removes the requirement for window to exist on the server. It will however be a breaking change for applications that implicitly expect the existence of window in all javascript environments.
The definition of window on the server could potentially be made a configuration option to mitigate errors.
This PR also updates React to version 15.3.2