-
Notifications
You must be signed in to change notification settings - Fork 334
Description
Describe the bug
Downgrading @vanilla-extract/webpack-plugin to 2.1.5 appears to resolve the issue.
In specific situations, it appears that all expected class names are not included. An example of the problem is seen with this error message, where the client is missing a class name. I have reproduced this in both a Next.js app and a Storybook app. After a fast refresh, like changing the color from green to red, it will start working again, but the initial build is always broken in both Next.js and Storybook.
Warning: Prop className did not match. Server: "Example__109b2pw2 sprinkles_width_100%__doo1ph0 Example__109b2pw1" Client: "sprinkles_width_100%__doo1ph0 Example__109b2pw1"
The example is not as reduced as I'd like yet, but there are a few requirements for the bug to happen afaik.
import { style } from "@vanilla-extract/css";
import { sprinkles } from "./sprinkles.css";
export const container = style([
sprinkles({
width: "100%"
}),
style([{ fontSize: "2em" }])
]);
export const label = style({
selectors: {
[`${container}:hover &`]: {
backgroundColor: "green"
}
}
});
stylemust be used with asprinklescall. Basic styles cannot be included directly here, it can only be composingsprinklesand otherstylecalls. The example is simplified, so I know including the nestedstyledoesn't make much sense in this context.- The return of that
styleis then used in another selector style. This is what makes or breaks the example. If that unique class name is not included in the DOM, then the label won't turn green on hover. - It seems like there needs to be another import that uses
sprinklesas well, hence theDivider.css.jsin the example. - The responsive properties in
sprinklesseem to matter as well.
Link to reproduction
https://codesandbox.io/s/affectionate-turing-kwrpqd
When working, hovering over Hello World should show the green background behind World. When broken, there is no change on hover.
System Info
Output of npx envinfo --system --npmPackages @vanilla-extract/css,@vanilla-extract/webpack-plugin,@vanilla-extract/esbuild-plugin,@vanilla-extract/vite-plugin,@vanilla-extract/sprinkles,webpack,esbuild,vite --binaries --browsers:
My reproduction with Storybook outside of Code Sandbox:
System:
OS: macOS 12.1
CPU: (10) x64 Apple M1 Max
Memory: 831.85 MB / 64.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.3 - ~/.volta/tools/image/node/14.17.3/bin/node
Yarn: 1.22.10 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn
npm: 6.14.13 - ~/.volta/tools/image/node/14.17.3/bin/npm
Browsers:
Chrome: 100.0.4896.88
Firefox: 98.0.1
Safari: 15.2
npmPackages:
@vanilla-extract/css: 1.6.8 => 1.6.8
@vanilla-extract/sprinkles: 1.4.0 => 1.4.0
@vanilla-extract/webpack-plugin: 2.1.7 => 2.1.7
webpack: 5.67.0 => 5.67.0