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

🙋 feature request: built-in SSR for using bundler middleware #737

Closed
3 tasks
dbkaplun opened this issue Feb 4, 2018 · 7 comments · Fixed by #10055
Closed
3 tasks

🙋 feature request: built-in SSR for using bundler middleware #737

dbkaplun opened this issue Feb 4, 2018 · 7 comments · Fixed by #10055
Labels

Comments

@dbkaplun
Copy link

dbkaplun commented Feb 4, 2018

  • Add an ssr option that, when enabled, renders React components into their including .html files, calling getInitialProps({req}) before rendering a la next.js
  • Extend server to call a render method on assets if ssr: true
  • Add a built-in render method to HTMLAsset that traverses linked assets, finds occurrences of ReactDOM.render/createPortal in JS/JSX files, and uses ReactDOMServer to render to a string and replace the contents of the HTML.

See also: #355

@devongovett
Copy link
Member

The problem with this request is that Parcel is not specific to react. So we must design our features in a generic way that considers all possible frameworks.

That being said, if there is a way to have parcel enable this in a generic way so that e.g. plugins could implement SSR for react and other frameworks, that would be awesome. Let's figure out what that looks like.

@lbguilherme
Copy link
Contributor

Just would like to add that for SSR to be useful, it is quite complicated. It must:

  • Resolve the route to render the correct component (react-router)
  • Understand how the application store state and transfer that state as well (rehydrate)
  • Wait for APIs/Database calls from the components so that the rendered result actually have some content
  • Do all of that with HMR?

And parcel serve is not a production server in any way, I don't think it should handle SSR. Maaaybe parcel would output a separated bundle suitable to run on Node that is a server with SSR for that application. But that sounds too much.

@dbkaplun
Copy link
Author

dbkaplun commented Jul 9, 2018

FWIW Rogue does this with Parcel+React.

@DeMoorJasper
Copy link
Member

I've also recently released https://github.com/DeMoorJasper/blazingly which is an experiment to create a universal and powerfull SSR server and cli tool for parcel (in the future blazingly will be stable and extendable)

I've also been chatting with the maintainer of Rogue on how to write Rogue as a blazingly extension

@st0ffern
Copy link

@DeMoorJasper i think there is a problem doing boilerplates or boilerplated-tools all the time.
This is why i created https://github.com/velop-io/server .

Supports multiple React apps, SSR, Webpack, HotReloading, Relay, Authenticated routes, FoundRouter, Graphql, custom routes +++ out of the box!

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Jul 10, 2018

@Stoffern I was actually thinking of rewriting certain parts of blazingly to make it extendable, probably similar to how other SSR projects are doing it.
Perhaps I'll find some time this weekend to dig into these improvements.

My main worry about supporting everything is that I dont's want to make the install gigantic, which is quite a bad thing, definitely as I'd like to make blazingly usable in production eventually (which isn't really possible if the install is ginormous, def on small cloud based servers).
The concept of blazingly in production is actually to create server and client bundles to run, so that the actual runtime of blazingly can be quite small and not responsible for anything except just running some scripts in a sandbox and serving some files (this could potentially also be hosted on a cdn)

@st0ffern
Copy link

take a look at https://github.com/velop-io/server then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants