stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: per-mode stylesheets do not load with dist-custom-elements in Next.js

Open liamdebeasi opened this issue 3 years ago • 2 comments

Prerequisites

Stencil Version

2.17.0

Current Behavior

Stylesheets do not load for components that have per-mode stylesheets (I.e. ios or md) in a Next.js application. This impacts dist-custom-elements in apps that rely on the setMode function which allows Stencil to correctly determine the mode for a component.

This function is set in a global component. However, it appears that in a Next.js application the global component is not always the first thing to load. As a result, when a Stencil component is mounted, the stylesheets do not load because the setMode callback was never provided.

Expected Behavior

I would expect to have a way to ensure that setMode is always called first.

Steps to Reproduce

See steps to reproduce in GitHub readme. The readme in next-app also has an overview of the different components.

Code Reproduction URL

https://github.com/liamdebeasi/stencil-next

Additional Information

I do not think this is a Stencil bug, but I am unclear as to how to get this working in a Next.js environment if I cannot find a way to ensure that setMode is always called first.

liamdebeasi avatar Jul 01 '22 20:07 liamdebeasi

can confirm this isn't working! I'm playing around with it a bit now to just see if there's some way I can get the function called before the component hits the DOM. It's possible we do need to make a change in Stencil here but atm not sure!

alicewriteswrongs avatar Jul 05 '22 19:07 alicewriteswrongs

Are there any updates?

MarianDabrowski avatar Sep 17 '22 11:09 MarianDabrowski

hi everyone, any updates on this?

ihormak avatar Oct 28 '22 08:10 ihormak

Hi all!

The Stencil team has confirmed that this is a bug and ingested it into our internal ticketing system for prioritization and so on. I can promise that when there are updates about the issue or a fix it will be noted here, until then I have nothing to report 🙂

alicewriteswrongs avatar Oct 28 '22 13:10 alicewriteswrongs