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

Initial Stack-Free SSR Implementation #9673

Merged
merged 27 commits into from
May 17, 2017
Merged

Conversation

tomocchino
Copy link
Contributor

This is an initial implementation of server rendering that doesn't depend on stack. It's basically all copy pasted code, shoved into a single file, but it will hopefully be able to be cleaned up and refactored if we decide to land this.

@@ -13,15 +13,15 @@

var ReactDOMInjection = require('ReactDOMInjection');
var ReactDOMStackInjection = require('ReactDOMStackInjection');
var ReactServerRendering = require('ReactServerRendering');
var ReactDOMServerRendering = require('ReactDOMServerRendering');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this into another file so that we can get the roll out. ReactDOMStreamServer?

'src/ReactVersion.js',
'src/shared/**/*.js',
'src/addons/**/*.js',
],
},
// TODO: there is no Fiber version of ReactDOMServer.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take this chance to duplicate the entry above to a new flat bundle entry for the new ReactDOMStreamServer module.


function resolve(child, context) {
if (Array.isArray(child)) {
throw new Error('well that was unexpected');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with an invariant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, duh.. @spicyj, what happens when child is passed in as an array (in a post-fiber world). Was this before we thought about fragments, since your original diff was from over a year ago? :P

);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
'Warning: Unknown event handler property onclick. Did you mean ' +
'`onClick`?\n in input (at **)',
'Warning: Unknown event handler property onclick. Did you mean `onClick`?',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the stacks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @spicyj again. We don't have the stacks in the server renderer so Ben told me to just remove these, but I'd be fine with trying to figure out how to add them back.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. I don't really mind since it's easier to debug things on the client anyway.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back to you so we can keep the old stack version and add a new bundle that we can put behind a flag.

sophiebits and others added 24 commits May 17, 2017 09:22
Originally authored by spicyj, tweakes to rebase it and make it run by tomocchino.

Adding ReactDOMServerRendering and a createTagMarkup utility function which will be used in it.
This is pretty hacky and I just inlined everything, but at least I sort of understand how it works now, and all of the tests are passing. There are also only 68 tests failing in the integration test suite.
This also reverts the changes I made to ReactDOMComponent-test.js which removed the stack which is missing in the new server renderer"
Moving src/renderers/dom/server/ReactDOMServerRendering.js to src/renderers/server/ReactServerRenderer.js and add src/renderers/server/ReactServer.js which makes this new codepath completely separate.
Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get it in!

@sebmarkbage sebmarkbage merged commit 8af7292 into facebook:master May 17, 2017
fbEntry: 'src/renderers/dom/ReactDOMServer.js',
hasteName: 'ReactDOMServerStack',
isRenderer: true,
label: 'dom-server',
manglePropertiesOnProd: false,
name: 'react-dom/server',
paths: [
'src/isomorphic/**/*.js',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. These changes are actually pretty bad. We're building all of isomorphic into these packages now.

props = Object.assign(
{
selected: undefined,
children: undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any (perf) benefit to pass same shape objects as arguments of Object.assign?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely depends on the engine and how it implements hidden class optimizations. In theory it helps provide a better layout for the fields.

@tomocchino tomocchino deleted the ssr branch August 19, 2021 18:55
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.

None yet

6 participants