-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Server: Use production react in the server bundle for prod #10693
Conversation
65448a6
to
3e8b929
Compare
Hmm, I think maybe this should go in the |
I had the plugin in the wrong place at first. It should be a webpack plugin, not a babel plugin. I also turned on minification so the runtime checks for NODE_ENV don't even happen now in prod. |
I only saw the |
:) The important thing here is to run the minified version of React, not to run with
By removing the chunk with the try block, V8 can optimize the function. With it in place, it will never optimize it. There's also other things that envify'ing react fixes that are not disabled simply by setting See https://twitter.com/dan_abramov/status/592691315374170113 |
Also raxjs/server-side-rendering-comparison#5
|
Sure, but we can set the env at build time without I guess I'm worried about other
Ah, hmm, good find. This is interesting. nodejs/node#3104 has some more details. |
How would we do that? |
Sorry, that was too terse. Yay phones. Setting the env at build time won't have any affect. I assume you mean something like
becomes
which is then sent to Uglify, which then removes the block in question because it can guarantee that the condition is always false. Setting the env var doesn't get us that. Now, if we have similar checks for environment vars in our code, we should add those to |
a8b0db9
to
7659d22
Compare
7659d22
to
49402a5
Compare
This was necessary as we treat So minifying/ |
As a possible follow on to this, we should check and see if other modules we're using server side take advantage of the same pattern (redux? redux-react?). Anything that's gating on |
Confirmed this works in a docker container |
Looks like redux does use it to check for unexpected keys https://github.com/reactjs/redux/blob/master/src/combineReducers.js#L139 |
Reworked to only remap to minified react (and now redux) in prod environments. |
Hrm. /design isn't loading completely on my local docker instance running wpcalypso with an incognito instance in Chrome. Works fine on https://wpcalypso.wordpress.com. Perhaps an https issue? SSR output looks the same. Guessing it's something with the local docker setup. |
Confirmed http://wpcalypso.wordpress.com/theme/mood works in a local docker env |
I get this too, same on FWIW only the masterbar is SSRed on logged-out /design.
Perhaps. It would be great if something like #9276 could allow us to mirror the different envs as closely as possible, including a reverse nginx proxy with self-signed SSL cert to avoid what I think are HSTS issues with testing http://wordpress.com locally? |
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.
Anyway, looks good to go to me :)
See https://twitter.com/eldh/status/821257104694579200
Currently we're running the debug build of react in our server process. This should switch it to be the production build, which should cut down render times a fair bit.