Replies: 2 comments 8 replies
-
can you switch to the CLI instead of the postcss plugin ? seems like NextJS has some specific issues |
Beta Was this translation helpful? Give feedback.
8 replies
-
I did switch to the CLI and that seems to have resolved it. I've ran through my steps 10 times just to be sure and I can't get in a broken state. Thanks for the suggestion. We will use that method with NextJS instead of the postcss plugin. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
There seems to be some sort of race condition or invalid state when running the postcss plugin with NextJS. There are times where frequently the resulting
layout.css
file does not contain therecipes.slots
or theutilities
layers in the resulting css file, the file only contains the reset, base, and tokens layers. I observed that the plugin was being invoked twice on each page load and sometimes both invocations would result in the same outputted css but other times the second invocation would be missing certain layers.I spent a couple days adding log statements and trying to track down the cause of the observed behavior. In my logfile, I noticed that the builder setup was being invoked twice each time I refreshed the page. The first invocation resulted in the proper outputted styles. This was observed by adding a logger in the
getCss
method ingenerator.ts
. But then the plugin was invoked a second time, and when that same method was invoked the outputted css did not contain the layers:utilties
andrecipes.slots
.I then tried to trace how those styles got included in the stylesheet. When the proper css was outputted, I noticed
collectAtomic
was invoked instyle-decoder.ts
and then afterwards theprocessCss
method was invoked instylesheet.ts
. When I got the wrong styles outputted, these methods were never called in the logs.Also, when I did observe the correct outputted styles, only the first invocation made calls to
processAtomic
.I was able to "resolve" it consistently by moving the creation of the
Builder
class in the postcss plugin to inside the plugin function. I did that as I suspected there may be some invalid state in that builder object between invocations of the plugin. I imagine I am losing out on some caching by doing this but for my team, it was better than having styles missing during development.Link to Reproduction
n/a
Steps to reproduce
npm run dev
.next/static/css/app/layout.css
, noticed it is missing two layers:utilities
andrecipes.slots
note: This didn't happen every time following the above steps. Maybe every 1 out of 4 it would be correct but it was not deterministic/consistent. I'd observe the behavior after a few attempts at following the above steps.
JS Framework
React (TS), NextJS (14.1.0)
Panda CSS Version
0.32.1
Browser
Any browser
Operating System
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions