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

fix: rewrite SSR client-side hydration #6067

Merged

Conversation

johnjenkins
Copy link
Contributor

@johnjenkins johnjenkins commented Nov 28, 2024

What is the current behavior?

There are lots of rough edges around the use of Stencil's proprietary non-shadow components during SSR

GitHub Issue Number:

What is the new behavior?

A partial re-write of client-hydrate.ts (and few minor tweaks in the accompanying files) fixes all these issues.

Documentation

Does this introduce a breaking change?

  • Yes
  • No

^ no breaking changes, but I should mention that during / after hydrating now, there are some changes to the outputted markup:

  • A couple more internal tags / comments from the server generated markup
  • Fewer Stencil-generated comment nodes left behind after hydration

These changes could potentially cause users' test snapshots to fail.

Users would just need to update their snapshots

Testing

New spec tests. New e2e tests.

Other information

Referring to the linked issues, here's the same repo with the fixes applied:

image

image

image

image

I appreciate, with a re-factor to client-hydrate.ts this big, there's a degree of 'trust me bra' involved - it's difficult to grok. I've done my best to add lots of comments to help elucidate it's dark magic, but if it's too much or too little just let me know. If you'd like me to talk through what it's doing just let me know :)

@johnjenkins johnjenkins requested a review from a team as a code owner November 28, 2024 13:58
@johnjenkins johnjenkins marked this pull request as draft November 28, 2024 13:59
@johnjenkins johnjenkins changed the title fix(hydration): refactoring client hydration fix: rewrite SSR client-side hydration Nov 29, 2024
@christian-bromann
Copy link
Member

@johnjenkins awesome work 👏 I am reviewing this, please give me until next week. I feel confident we can merge and publish this relatively quickly when test pass and coverage was adjusted properly.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Fantastic work 👏 I really appreciate you helping out with these essential runtime improvements. I've been working on Stencil now for more than a year and still feel very confused in many areas here. So while I still don't 100% understand all code changes I feel confident moving forward with this as the code is clearly written, comments added and test coverage increased. I would love to schedule a session with you enventually for some learn more about everything you know about this.

Thanks a ton!

@christian-bromann christian-bromann merged commit ec243c2 into stenciljs:main Dec 10, 2024
88 checks passed
@johnjenkins
Copy link
Contributor Author

Absolute pleasure.
Quite honestly… it’s just the most rewarding thing seeing this stuff finally get merged.
❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment