55# LICENSE file in the root directory of this source tree.
66slug : v0.17.1
77title : Release 0.17.1
8- authors : [mellyeliu, nmn ]
8+ authors : [nmn, mellyeliu ]
99tags :
1010 - release
1111---
1212
1313# Release 0.17.1
1414
15- StyleX v0.17 introduces a safe and composable solution to descendent and sibling selectors with ` stylex.when.* ` ,
16- an all new unplugin package for improved integration with various modern bundlers and a slew of fixes and improvements.
15+ StyleX v0.17 introduces an all new unplugin package for improved integration with various modern bundlers,
16+ the ability to define custom markers to be be used alongside the ` stylex.when.* ` APIs, and a slew of bug-fixes
17+ and improvements.
18+
19+ ## New ` @stylexjs/unplugin ` package
20+
21+ Stylex 0.17 comes with a new ` @stylexjs/unplugin ` package that use the excellent ` unplugin ` library to create a near-universal bundler
22+ plugin that works with Vite, Rollup, Webpack, Rspack, Esbuild, and more. In supported project setups, this new package should offer
23+ the best developer experience and performance for StyleX integration. We have introduced new
24+ [ examples] ( https://github.com/facebook/stylex/tree/main/examples ) in the github repository for using
25+ Webpack, RSPack and various Vite setups, (including RSCs, React-Router, Waky and RedwoodSDK).
26+ When applicable we are testing both production builds and HMR in development builds.
27+
28+ We look forward to expanding this set of examples with more common frameworks and bundler setups.
29+
30+ For frameworks that are not yet supported by our unplugin package, we continue to maintain the ` @stylexjs/postcss-plugin ` and
31+ and ` @stylexjs/cli ` packages for maximum compatibitiy.
32+
1733
1834## Custom Markers for ` stylex.when.* ` APIs
1935
@@ -30,18 +46,36 @@ StyleX 0.17 introduces one new API to create custom named markers, `stylex.defin
3046
3147Using these APIs, a typical CSS selector such as ` .parent:hover .child ` can be implemented as:
3248
49+ import { Card } from ' ../components/StyleXWhenDemo/Card' ;
50+
51+ <Card />
52+
3353``` tsx
34- // markers.stylex.js
54+ // markers.stylex.ts
3555import * as stylex from ' @stylexjs/stylex' ;
3656
3757export const cardMarker = stylex .defineMarker ();
38- export const buttonMarker = stylex .defineMarker ();
58+ export const btn = stylex .defineMarker ();
59+ ```
3960
61+ ``` tsx
4062// Card.tsx
4163import * as stylex from ' @stylexjs/stylex' ;
42- import { cardMarker , buttonMarker } from ' ./markers.stylex' ;
64+ import { cardMarker , btnMarker } from ' ./markers.stylex' ;
4365import {tokens } from ' ./tokens.stylex' ;
4466
67+ export function Card() {
68+ return (
69+ <article { ... stylex .props (styles .card , cardMarker )} >
70+ <p >Markers let siblings and ancestors opt into the same state.</p >
71+ <button { ... stylex .props (btnMarker , styles .cta )} >
72+ Action
73+ <ArrowIcon style = { styles .icon } />
74+ </button >
75+ </article >
76+ );
77+ }
78+
4579const styles = stylex .create ({
4680 card: {
4781 borderWidth: 1 ,
@@ -51,101 +85,60 @@ const styles = stylex.create({
5185 cta: {
5286 backgroundColor: {
5387 default: ' black' ,
54- [stylex .when .ancestor (' :focus-visible ' , cardMarker )]: tokens .accent ,
88+ [stylex .when .ancestor (' :hover ' , cardMarker )]: tokens .accent ,
5589 },
5690 color: ' white' ,
5791 },
5892 icon: {
5993 opacity: {
6094 default: 0 ,
61- [stylex .when .ancestor (' :focus-visible ' , cardMarker )]: 1 ,
95+ [stylex .when .ancestor (' :hover ' , cardMarker )]: 1 ,
6296 },
6397 transform: {
6498 default: ' translateX(0)' ,
65- [stylex .when .ancestor (' :focus-visible ' , buttonMarker )]: ' translateX(4px)' ,
99+ [stylex .when .ancestor (' :hover ' , btnMarker )]: ' translateX(4px)' ,
66100 }
67101 }
68102});
69-
70- export function Card() {
71- return (
72- <article { ... stylex .props (styles .card , cardMarker )} >
73- <p >Markers let siblings and ancestors opt into the same state.</p >
74- <button { ... stylex .props (buttonMarker , styles .cta )} >
75- Action
76- <ArrowIcon style = { styles .icon } />
77- </button >
78- </article >
79- );
80- }
81103```
82104
83105Icon in the button appears when card is hovered, but it moves to the right when the button itself is hovered.
84106
107+ ## Updating default configuration options
85108
86- ## New ` @stylexjs/unplugin ` package
87-
88- The new ` @stylexjs/unplugin ` package is now the recommended way to use StyleX with modern bundlers like Vite, Webpack, RSpack, and Rollup.
89-
90- Unlike the StyleX PostCSS plugin, the unplugin instance integrates directly into the module graph of your bundler and doesn't need to
91- transform your JS files twice. This should give you better build times, more reliable hot module replacement (HMR), and an easier setup.
109+ We are updating some of the default StyleX configuration options to help make the builds more consistent across development
110+ and production and improve the developer experience in many scenarios.
92111
93- The unplugin integrates directly into the module graph of your bundler. This means StyleX files are transformed once as part of the standard
94- build process, eliminating the need for a separate PostCSS step. This approach is faster, supports more reliable hot module replacement (HMR),
95- and correctly handles StyleX code within ` node_modules ` without additional configuration.
112+ ### ` enableDebugClassNames ` is now disabled by default
96113
97- If you are currently using the PostCSS plugin, we recommend switching to the unplugin for a smoother experience.
114+ Enabling this option will emit classNames that reference the CSS property being applied, and CSS variable names
115+ that are prefixed with the name used in source. However, generating incompatible CSS in development and production
116+ can cause caching-related bugs in some setups and so we are disabling this option by default.
98117
99- Please see the examples in the ` examples/ ` directory for more examples and documentation on how to use StyleX within
100- various common React frameworks and bundler setups.
118+ ### ` data-style-src ` prop now shows full file paths
101119
102- ## Other Improvements
103-
104- - Added runtime injection support for ` defineConsts ` , so HMR works with changes to constants.
105- - Default config options are aligned across bundlers and the compiler.
106- - Media queries that start with ` screen and ` now order correctly, and complex media query keywords print as expected.
107- - Debug builds show full file paths instead of abbreviated ones.
108- - Dependency updates, including Jest, to pick up the latest fixes.
120+ The ` data-style-src ` prop is injected in addition to ` className ` and ` style ` during development to help identify the
121+ list of style objects applied to to the element in order or application. Previously, it showed only the last two segments
122+ of the file path which can be confusing.
109123
124+ Now, the it will include the full path relative to the nearest ` package.json ` file. For third-party package, we will also
125+ include the package name itself.
110126
111- ## ESLint improvements
127+ ### ` enableDevClassNames ` will now be enabled when ` dev ` is enabled
112128
113- - [ eslint-plugin] add ` legacyAllowMixedExports ` config to ` enforce-extension ` by @mellyeliu in #1305
114- - [ eslint-plugin] enforce ` defineConsts ` only extension by @mellyeliu in #1311
115- - [ eslint-plugin] disallow default exports from ` defineVars ` and ` defineConsts ` in ` enforce-extension ` by @mellyeliu in #1313
116- - [ eslint-plugin] enhance validation for ternary and logical expressions in style properties by @hiteshshetty-dev in #1266
117- - [ eslint-plugin] order pseudo-classes and ` stylex.when ` selectors according to the priorities by @yjoer in #1287
129+ The ` dev ` option inserts additional classNames that help identify where various classNames are coming from.
118130
119- ### Improvements and bug fixes
120- - [ babel-plugin] Bump specificity of ` stylex.when ` selectors over defaults by @mellyeliu in #1326
121- - Enhance ` stylex.props ` to precompile more often by @nmn in #1242
122- - [ babel-plugin] additional externals for rollup build by @henryqdineen in #1307
123- - [ babel-plugin] Remove confusing ` removeObjectsWithSpreads() ` utility by @henryqdineen in #1291
124131
125- ### Documentation
126- - [ docs] Add docs for ` stylex.when ` by @mellyeliu in #1327
127- - [ docs] add documentation for new ESLint rules by @mellyeliu in #1325
128- - [ docs] fix broken link, incorrect rule names by @henryqdineen in #1310
129- - [ docs] add team members by @mellyeliu in #1321
130- - Add example on chaining keyframes by @Joha99 in #1316
132+ ## Other Improvements
131133
132- ### Type improvements
133- - [ types] Restructure ` GenStylePropType ` Typescript type for more readable error messages by @j-malt in #1308
134- - [ types] Fix TypeScript constraint error in ` CSSType ` union by @henryqdineen in #1306
135- - [ types] Remove duplicate property declaration by @henryqdineen in #1315
136- - [ types] Flow types fix for ` stylex.when.* ` by @nmn in #1276
137- - [ babel-plugin] [ legacy ] Polyfill logical float values by @abhakat in #1237
134+ - Added support for handling ` defineConsts ` correctly when runtime injection is enabled.
135+ - Fixed a bug sometimes that caused invalid CSS output when Media Queries use ` screen and ` conditionals
136+ - Dependency updates, including Jest, to pick up the latest fixes.
137+ - Specificity improvements when using ` stylex.when.* ` selectors alongside regular pseudo-classes.
138+ - Expand how often ` stylex.props ` is precompiled to improve performance.
139+ - Various improvements to Flow and Typescript types (thanks, @j-malt , @henryqdineen )
140+ - Various improvements and fixes to the ESlint plugin (thanks, @hiteshshetty-dev , @yjoer )
138141
139- ### Internal tooling & infrastructure
140- - chore: format mjs files with prettier by @henryqdineen in #1309
141- - Add ` defineConsts ` usage to benchmark by @j-malt in #1312
142- - Fix internal meta sync by @vincentriemer in #1319
143142
144- ### Release
145- - [ release] v0.17.0 by @mellyeliu in #1328
146143
147- ### New contributors
148- - @j-malt made their first contribution in #1308
149- - @Joha99 made their first contribution in #1316
150144
151- Full Changelog: 0.16.3...0.17.0
0 commit comments