stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: hydrated flag doesn't work for dist-custom-elements build

Open MaksimShakavin opened this issue 2 years ago • 12 comments

Prerequisites

Stencil Version

2.11.0

Current Behavior

.hydrated class is not been added to component if I usedist-custom-elements bundle. Because of this I can see component flickering without styles while loading. And also I have some logic in componentDidLoad that rely on some dom elements width. It works from time to time depending on when styles are applied. With dist output everything works as expected.

Expected Behavior

.hydrated class is working for both lazy-loading from dist output target and general dist-custom-elements

Steps to Reproduce

Check out the reproduction repo. Run yarn install yarn build npx http-server packages/parcel-app/dist

Code Reproduction URL

https://github.com/MaksimShakavin/stencil-hydrated-bug

Additional Information

No response

MaksimShakavin avatar Jun 24 '22 07:06 MaksimShakavin

Hi @MaksimShakavin I am able to build and run your reproduction repo, thanks for providing that! Could you share some more specific information about what is currently happening in that repo that you're expecting not to be the case? I can see a simple test component rendering but I don't see any flickering or anything like that. Thanks!

alicewriteswrongs avatar Jun 27 '22 17:06 alicewriteswrongs

Hi @alicewriteswrongs , thanks for looking into it. There is no flickering because component's styles are very simple. The key problem is that '.hydrated' class is not added to the component, if dist-custom-elements is used. Or is it expected and invisiblePrehydration only works for dist?

MaksimShakavin avatar Jun 27 '22 18:06 MaksimShakavin

@MaksimShakavin I believe this may be a duplicate of #3319, does that issue look like it describes your issue accurately to you? If so, I'll close this in favor of that one since it is already prioritized and in our work backlog.

alicewriteswrongs avatar Jun 28 '22 13:06 alicewriteswrongs

Hi @alicewriteswrongs , it could be related but not exactly the same. In the bug above the problem is with hydration of pre-rendered html, not with invisiblePrehydration.

MaksimShakavin avatar Jun 30 '22 15:06 MaksimShakavin

Hi @alicewriteswrongs , I've pushed and update to the reproduction repo to show you the flash Of unstyled content, that I am facing. It appears that I can reproduce it only in firefox and only if I have nested web-components. In my example button-component is used inside my-component. And only for dist-custom-elements. flicker-bug

MaksimShakavin avatar Jul 10 '22 20:07 MaksimShakavin

For more complex components, like one that we have in our project with tons of content the page loads in the following sequence:

  1. Blank page
  2. Unstyled content
  3. Blank page
  4. Components with an applied styles

MaksimShakavin avatar Jul 10 '22 20:07 MaksimShakavin

On of our projects historically uses parcel, and dist doesn't work with it ,because of the issue described in https://github.com/ionic-team/stencil/issues/1882 . One of the solution is to use dist-custom-elements, but it doesn't work for us neither because of this bug.

MaksimShakavin avatar Jul 11 '22 12:07 MaksimShakavin

We encountered this as well. In case it helps, here's another repro case closer to our setup.

jcfranco avatar Jul 13 '22 23:07 jcfranco

@jcfranco thanks for the additional reproduction, I'll mark this for further discussion and prioritization.

alicewriteswrongs avatar Jul 15 '22 15:07 alicewriteswrongs

Any update about the prioritization ? Facing the same issue and use pre-hydration style for most of my library. I can only use dist atm :)

KevinCarnaille2 avatar Nov 04 '22 08:11 KevinCarnaille2

Hi @rwaskiewicz , is there any progress on this issue?

MaksimShakavin avatar Feb 13 '23 15:02 MaksimShakavin