-
Notifications
You must be signed in to change notification settings - Fork 360
Description
Describe the issue
when there are multiple stylex.defineVars in a file all of them are added to the CSS in dev mode even if not all are imported
Expected behavior
tree shaking correctly removes unused stylex.defineVars calls
Steps to reproduce
index.tsx
import * as stylex from "@stylexjs/stylex";
import { Pink } from "./variable.stylex";
const styles = stylex.create({
color: {
color: Pink.pink,
},
});
export function Playground() {
return (
<div>
<span {...stylex.props(styles.color)}>test</span>
</div>
);
}variable.stylex.ts
import * as stylex from "@stylexjs/stylex";
export const Pink = /*@__PURE__*/ stylex.defineVars({
pink: "pink",
});
export const Green = /*@__PURE__*/ stylex.defineVars({
green: "green",
});Green will end up being included in the css in dev mode, and thus the extrenous --green-<id> variable will end up being included.
Test case
run bun install
run bun run dev
(though any package manager should work)
https://github.com/Mkassabov/stylex-vite-tree-shaking
observe that the green variable has been added
Additional comments
adding /*@__PURE__*/ to signify these shouldn't be included in dev mode also doesn't work
The main reason for wanting this is we add our entire color system (which is some ~7500 colors) as stylex styles. the vast majority of which aren't used; this causes the chrome dev tools to become extremely slow