microsite: Hydration fails when a component is used on multiple pages
Version: 1.1.0-next.3
Steps to reproduce
- Render a hydrated component on multiple pages
- Build/serve
- Load in browser
Expected behavior
The component will hydrate on each page.
Observed behavior
No JS is loaded at all.
Apparent cause
Any shared component with hydration is bundled as a shared chunk, but the shared chunk is excluded from hydrateBindings
, and doesn’t appear to be referenced anywhere else. If I comment out that check it does hydrate as expected.
I was tempted to offer a PR removing that check, but I can’t shake the feeling that there’s a reason it’s there and the intent was to handle that case differently.
Related side note: in terms of contribution, my usual approach is to write a failing test exercising my bug, then fix to make the test pass. But at present Microsite doesn’t appear to have a test suite. Is that something you’d be interested in? If so do you have a preferred test framework? I’d be happy to look into setting up CI for any tests I contribute, and to try to increase coverage as I contribute.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (5 by maintainers)
Without getting too hung up on the big testing question, I strongly suspect the resolution of this is pretty simple:
Great news! I got a little proof of concept with Estrella working, and goodness it is fast! And it took very little fuss to get going. I’m going to clean up some mess, setup a GitHub Action, and push up a PR. It’s not a huge diff, but I think I’d like to keep test setup separate from fixing this issue to get a meaningful win. Hopefully ready within the hour!
Wow thank you! Gonna start digging into tests for this issue!
@eyelidlessness I invited you to this repo. Feel free to make branches and PRs here instead of on a fork, please just add me as a reviewer on any PRs!
I should also add, part of the reason for all the big upfront questions (it’s okay if you’re squishy on any of them btw) is because I want to make sure I’m being a good citizen/visitor when I contribute, especially if I’m introducing anything new. And also because I see a lot of potential here and want to take it as seriously as I would take starting on a new team with a project I’m gonna be living with and wake up thinking about (which no joke I did today, with my dev setup so close I can almost taste it). Just saying, I’m sorry again for blowing up your notifications but I’m seriously excited to work with this project.
Oops I meant to add more on the refactor topic. There are definitely cases where I see opportunities here. If I were to try anything big I’d definitely want to open a discussion issue/chat first. Most prominent are (as mentioned) anywhere I see
any
types, and some functions in the build flow that are quite large which can be hard to follow. I’m definitely not looking to come in and throw weight around, but this is something I inevitably encounter in new-to-me projects and I find it helpful to ask upfront on other people’s projects (and I tend to be imperious when they’re mine, so I understand any fraction of same).Hmm, I’ll have to look into this. You’ve definitely diagnosed the problem correctly, I don’t think it’s anything with your setup. I’m trying to remember if there was a reason I was ignoring the shared chunk in
hydrateBindings
…As for the tests, yes please! 🎉 Microsite desperately needs tests. I was moving fast and breaking things (and also didn’t expect this gain traction) so I skipped them. I think
uvu
would be a good fit, and your PR can start small. Any help with CI would much appreciated!