Skip to content

refactor(ServerRendering) simpler server rendering assets #471

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

Merged
merged 3 commits into from
Apr 4, 2017

Conversation

rmosolgo
Copy link
Member

@rmosolgo rmosolgo commented Feb 8, 2016

We have a problem with Sprockets 3.

  • We add lib/assets/react-source/{ production | development } to the asset pipeline
  • This makes it so //= require react works for production build or development build
  • For some reason, Sprockets 3 puts those files in the manifest as production/react-server instead of react-server (Server-side rendering is not working with sprockets-rails 3.0 #443 (comment))
  • As a result, we can't find the file from the manifest. (The logical_path has changed!)

Why does it do that?! I don't know. But I think this is a chance to simplify the default server rendering setup.

Right now, we require ["react-server.js", "components.js"]. Because react-server is "automatic", it's a bit hidden. I think we should add a new file called server_rendering.js which includes those two files. This is good because:

  • By default, you have total control over the SSR manifest
  • Less "automatic" stuff that can just break and stop you from building a sweet app
  • react-server.js becomes a public API (I'm using this for my app already, I need renderToString)

However, this introduces some breaking changes:

  • To upgrade, you should add the server_rendering.js manifest

TODO:

  • Why are the compiled assets different?

@rmosolgo rmosolgo force-pushed the ssr-js-refactor branch 3 times, most recently from 1529feb to d6db908 Compare February 23, 2016 03:10
@franzejr
Copy link

I agree README is not totally friendly related to the react-server file.

@caseys
Copy link

caseys commented Mar 28, 2017

"automatic" react-server.js has been confusing for me too.

@rmosolgo rmosolgo changed the base branch from master to 2.0-dev April 4, 2017 15:28
@rmosolgo rmosolgo modified the milestone: 2.0.0 Apr 4, 2017
@rmosolgo rmosolgo merged commit c248b9f into 2.0-dev Apr 4, 2017
@rmosolgo rmosolgo deleted the ssr-js-refactor branch April 4, 2017 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants