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

SSR Hydration #2552

Merged
merged 39 commits into from
Apr 2, 2022
Merged

SSR Hydration #2552

merged 39 commits into from
Apr 2, 2022

Conversation

futursolo
Copy link
Member

@futursolo futursolo commented Mar 26, 2022

Description

Closes #2453 (Supersedes it).
Closes #41.

This pull request introduces Renderer::hydrate and SSR Hydration.

Checklist

  • I have run cargo make pr-flow
  • I have reviewed my own code
  • I have added tests

# Conflicts:
#	.github/workflows/main-checks.yml
#	examples/agents/Cargo.toml
#	examples/boids/Cargo.toml
#	examples/contexts/Cargo.toml
#	examples/counter/Cargo.toml
#	examples/dyn_create_destroy_apps/Cargo.toml
#	examples/file_upload/Cargo.toml
#	examples/function_memory_game/Cargo.toml
#	examples/function_router/Cargo.toml
#	examples/function_router/index.html
#	examples/function_todomvc/Cargo.toml
#	examples/futures/Cargo.toml
#	examples/game_of_life/Cargo.toml
#	examples/inner_html/Cargo.toml
#	examples/js_callback/Cargo.toml
#	examples/keyed_list/Cargo.toml
#	examples/mount_point/Cargo.toml
#	examples/nested_list/Cargo.toml
#	examples/node_refs/Cargo.toml
#	examples/password_strength/Cargo.toml
#	examples/portals/Cargo.toml
#	examples/portals/src/main.rs
#	examples/router/Cargo.toml
#	examples/suspense/Cargo.toml
#	examples/timer/Cargo.toml
#	examples/todomvc/Cargo.toml
#	examples/two_apps/Cargo.toml
#	examples/web_worker_fib/Cargo.toml
#	examples/webgl/Cargo.toml
#	packages/yew-router/Cargo.toml
#	packages/yew/Cargo.toml
#	packages/yew/Makefile.toml
#	packages/yew/src/app_handle.rs
#	packages/yew/src/dom_bundle/bcomp.rs
#	packages/yew/src/dom_bundle/bportal.rs
#	packages/yew/src/dom_bundle/bsuspense.rs
#	packages/yew/src/dom_bundle/btag/listeners.rs
#	packages/yew/src/dom_bundle/btag/mod.rs
#	packages/yew/src/dom_bundle/btext.rs
#	packages/yew/src/dom_bundle/mod.rs
#	packages/yew/src/dom_bundle/traits.rs
#	packages/yew/src/dom_bundle/utils.rs
#	packages/yew/src/html/component/lifecycle.rs
#	packages/yew/src/html/component/mod.rs
#	packages/yew/src/html/component/scope.rs
#	packages/yew/src/html/mod.rs
#	packages/yew/src/lib.rs
#	packages/yew/src/renderer.rs
#	packages/yew/src/scheduler.rs
#	packages/yew/src/server_renderer.rs
#	packages/yew/src/suspense/component.rs
#	packages/yew/src/suspense/mod.rs
#	packages/yew/src/tests/layout_tests.rs
#	packages/yew/src/virtual_dom/vcomp.rs
#	packages/yew/src/virtual_dom/vlist.rs
#	packages/yew/src/virtual_dom/vsuspense.rs
#	packages/yew/src/virtual_dom/vtag.rs
#	packages/yew/src/virtual_dom/vtext.rs
#	tools/website-test/Cargo.toml
#	website/docs/advanced-topics/portals.mdx
#	website/docs/getting-started/build-a-sample-app.mdx
#	website/docs/tutorial/index.mdx
github-actions[bot]
github-actions bot previously approved these changes Mar 26, 2022
@github-actions
Copy link

github-actions bot commented Mar 26, 2022

Visit the preview URL for this PR (updated for commit a339020):

https://yew-rs--pr2552-hydration-3-lgz3svc0.web.app

(expires Sat, 09 Apr 2022 12:41:20 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@github-actions
Copy link

github-actions bot commented Mar 26, 2022

Size Comparison

examples master (KB) pull request (KB) diff
boids 311.369 311.361 -0.008
contexts 233.373 232.225 -1.148
counter 164.553 164.661 +0.108
dyn_create_destroy_apps 172.898 172.880 -0.019
file_upload 194.978 195.101 +0.123
function_memory_game 351.633 349.353 -2.280
function_router 22.254 406.764 +384.510
function_todomvc 327.007 325.313 -1.693
futures 362.343 362.467 +0.124
game_of_life 207.214 207.341 +0.127
inner_html 156.413 156.521 +0.108
js_callback 171.900 172.026 +0.126
keyed_list 329.064 329.185 +0.120
mount_point 163.721 163.830 +0.109
nested_list 225.380 225.504 +0.124
node_refs 170.801 170.927 +0.126
password_strength 1851.782 1851.823 +0.041
portals 184.308 184.418 +0.110
router 589.902 588.481 -1.421
simple_ssr N/A 576.700 N/A
ssr_router N/A 497.603 N/A
suspense 222.804 221.720 -1.084
timer 170.391 170.514 +0.123
todomvc 270.740 270.753 +0.013
two_apps 166.012 166.137 +0.125
webgl 170.815 170.941 +0.126

github-actions[bot]
github-actions bot previously approved these changes Mar 26, 2022
github-actions[bot]
github-actions bot previously approved these changes Mar 26, 2022
github-actions[bot]
github-actions bot previously approved these changes Apr 1, 2022
Copy link
Member

@WorldSEnder WorldSEnder left a comment

Choose a reason for hiding this comment

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

Found the time to review it in more detail.

examples/ssr_router/Cargo.toml Show resolved Hide resolved
packages/yew/src/dom_bundle/blist.rs Show resolved Hide resolved
packages/yew/src/dom_bundle/bsuspense.rs Outdated Show resolved Hide resolved
packages/yew/src/dom_bundle/bsuspense.rs Show resolved Hide resolved
packages/yew/src/dom_bundle/fragment.rs Show resolved Hide resolved
website/docs/advanced-topics/server-side-rendering.md Outdated Show resolved Hide resolved
website/docs/advanced-topics/server-side-rendering.md Outdated Show resolved Hide resolved
website/docs/advanced-topics/server-side-rendering.md Outdated Show resolved Hide resolved
website/docs/advanced-topics/server-side-rendering.md Outdated Show resolved Hide resolved
website/docs/advanced-topics/server-side-rendering.md Outdated Show resolved Hide resolved
github-actions[bot]
github-actions bot previously approved these changes Apr 2, 2022
github-actions[bot]
github-actions bot previously approved these changes Apr 2, 2022
github-actions[bot]
github-actions bot previously approved these changes Apr 2, 2022
github-actions[bot]
github-actions bot previously approved these changes Apr 2, 2022
github-actions[bot]
github-actions bot previously approved these changes Apr 2, 2022
github-actions[bot]
github-actions bot previously approved these changes Apr 2, 2022
Copy link
Member

@WorldSEnder WorldSEnder left a comment

Choose a reason for hiding this comment

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

Looks reasonably complete to approve this. As always, thanks for all the effort ❤️

Comment on lines 184 to +185
Example: [simple\_ssr](https://github.com/yewstack/yew/tree/master/examples/simple_ssr)
Example: [ssr\_router](https://github.com/yewstack/yew/tree/master/examples/ssr_router)
Copy link
Member

Choose a reason for hiding this comment

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

I would bring these in line with how it's placed in other places:

## Further reading

- The [`simple_ssr`](https://github.com/yewstack/yew/tree/master/examples/simple_ssr) example
- The [`ssr_router`](https://github.com/yewstack/yew/tree/master/examples/ssr_router) example

It's not blocking and can be done in a future PR


[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.15.0", features = ["full"] }
warp = "0.3"
Copy link
Member

Choose a reason for hiding this comment

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

I haven't tried it. I will give it a shot later. We can merge it in as-is and I will hopefully update it soon. I'm probably going to need some help from the #axum in tokio's server though...

@ranile
Copy link
Member

ranile commented Apr 2, 2022

@futursolo feel free to merge it if there's no more changes you want to make here.

@futursolo futursolo merged commit e46ae55 into yewstack:master Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Proposal: Server-side rendering
3 participants