Not tree shaking styles during dev mode
- Dominant language
- JavaScript
- Stars
- 10.3k
- Forks
- 481
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 13
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
```tsx
import * as stylex from "@stylexjs/stylex";
import { Pink } from "./variable.stylex";
const styles = stylex.create({
color: {
color: Pink.pink,
},
});
export function Playground() {
return (
test
);
}
```
variable.stylex.ts
```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-` 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
Contributor guide
Assessment
This issue has not been assessed yet.