-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: I was running into facebook/react#6451 even though I'm on React 15.3.1 and `npm ls | grep object-assign` shows only `object-assign@4.1.0`. A bit of debugging shows that the polyfill wasn't being applied early enough in the node bundle that's used for server-side rendering; we have to be sure to include it before any React components are used, so we might as well make it the very first thing! Test Plan: Load localhost:8080/skills and see that there aren't any SSR errors.
- Loading branch information
Showing
2 changed files
with
16 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
/* | ||
* Main entry point. Exports a function to do server-side rendering, | ||
* and runs client initialization (rehydration) code if on the frontend. | ||
* | ||
* Note that this module _is_ transpiled by Babel. However, we want to | ||
* require the `object-assign` polyfill before _anything_ else happens. | ||
* As a consequence, we can't use the ES6 module syntax, because Babel | ||
* hosts these imports---including `export ... from` forms---to the very | ||
* top of the file. So we manually define the exports, old-school style. | ||
*/ | ||
|
||
import initializeClient from './client'; | ||
Object.assign = null; | ||
Object.assign = require("object-assign"); | ||
|
||
if (typeof document !== "undefined") { | ||
initializeClient(); | ||
const isServerRendering = typeof document === "undefined"; | ||
|
||
if (!isServerRendering) { | ||
require("./client").default(); | ||
} | ||
|
||
export {default} from './server'; | ||
module.exports = { | ||
default: require("./server.js").default, | ||
}; |