An open source design system that's fully customizable and agent ready
TypeScript
chore: migrate to unplugin, fix configs and stylex antipatterns (#20)
mellyeliue250ff6f13f7
diff --git a/apps/storybook/.babelrc.cjs b/apps/storybook/.babelrc.cjsdeleted file mode 100644index 6000183dbd..0000000000--- a/apps/storybook/.babelrc.cjs+++ /dev/null@@ -1,36 +0,0 @@-/**- * @file .babelrc.cjs- * @input Uses @babel/preset-react, @babel/preset-typescript, @stylexjs/babel-plugin- * @output Babel configuration for React/TypeScript with StyleX- * @position Build config; used by Vite and PostCSS for transpilation- */--const path = require('path');--const rootDir = path.join(__dirname, '../..');--module.exports = {- presets: [- ['@babel/preset-react', { runtime: 'automatic' }],- '@babel/preset-typescript',- ],- plugins: [- [- '@stylexjs/babel-plugin',- {- dev: true,- runtimeInjection: true,- genConditionalClasses: true,- treeshakeCompensation: true,- aliases: {- '@xds/core/*': [path.join(rootDir, 'packages/core/src/*')],- '@xds/core': [path.join(rootDir, 'packages/core/src')],- },- unstable_moduleResolution: {- type: 'commonJS',- rootDir: rootDir,- },- },- ],- ],-};diff --git a/apps/storybook/package.json b/apps/storybook/package.jsonindex ad3176ff61..3600ee8e63 100644--- a/apps/storybook/package.json+++ b/apps/storybook/package.json@@ -12,9 +12,6 @@"react-dom": "^18.3.0"},"devDependencies": {- "@babel/core": "^7.28.5",- "@babel/preset-react": "^7.28.5",- "@babel/preset-typescript": "^7.28.5","@storybook/addon-essentials": "^8.4.0","@storybook/addon-interactions": "^8.4.0","@storybook/addon-links": "^8.4.0",@@ -22,9 +19,7 @@"@storybook/react": "^8.4.0","@storybook/react-vite": "^8.4.0","@storybook/test": "^8.4.0",- "@stylexjs/babel-plugin": "^0.17.4",- "@stylexjs/postcss-plugin": "^0.17.5",- "autoprefixer": "^10.4.23",+ "@stylexjs/unplugin": "^0.17.4","storybook": "^8.4.0"}}diff --git a/apps/storybook/postcss.config.mjs b/apps/storybook/postcss.config.mjsdeleted file mode 100644index f2acb6da46..0000000000--- a/apps/storybook/postcss.config.mjs+++ /dev/null@@ -1,30 +0,0 @@-/**- * @file postcss.config.mjs- * @input Uses postcss, @stylexjs/postcss-plugin, autoprefixer- * @output PostCSS configuration for StyleX processing- * @position Build config; used by Vite for CSS processing- */--import autoprefixer from 'autoprefixer';-import stylexPlugin from '@stylexjs/postcss-plugin';-import babelrc from './.babelrc.cjs';--export default {- plugins: [- stylexPlugin({- include: [- 'stories/**/*.{ts,tsx}',- '../../../packages/core/src/**/*.{ts,tsx}',- ],- babelConfig: {- babelrc: false,- parserOpts: {- plugins: ['typescript', 'jsx'],- },- ...babelrc,- },- useCSSLayers: process.env.NODE_ENV !== 'development',- }),- autoprefixer(),- ],-};diff --git a/apps/storybook/vite.config.ts b/apps/storybook/vite.config.tsindex 05c3a5a4aa..22a2674f6f 100644--- a/apps/storybook/vite.config.ts+++ b/apps/storybook/vite.config.ts@@ -1,7 +1,7 @@/*** @file vite.config.ts- * @input Uses vite, @vitejs/plugin-react, babel config- * @output Vite configuration with React/StyleX via Babel+ * @input Uses vite, @vitejs/plugin-react, @stylexjs/unplugin+ * @output Vite configuration with React and StyleX via unplugin* @position Build config; used by Storybook's Vite integration** SYNC: When modified, update this header and /apps/storybook/README.md@@ -9,18 +9,28 @@import { defineConfig } from 'vite';import react from '@vitejs/plugin-react';+import stylex from '@stylexjs/unplugin';import path from 'path';-// eslint-disable-next-line @typescript-eslint/no-require-imports-const babelrc = require('./.babelrc.cjs');-+const rootDir = path.resolve(__dirname, '../..');const coreRoot = path.resolve(__dirname, '../../packages/core/src');export default defineConfig({plugins: [- react({- babel: babelrc,+ stylex.vite({+ dev: process.env.NODE_ENV === 'development',+ useCSSLayers: true,+ styleResolution: 'application-order',+ aliases: {+ '@xds/core/*': [path.join(rootDir, 'packages/core/src/*')],+ '@xds/core': [path.join(rootDir, 'packages/core/src')],+ },+ unstable_moduleResolution: {+ type: 'commonJS',+ rootDir: rootDir,+ },}),+ react(),],resolve: {alias: {diff --git a/packages/core/src/Button/XDSButton.tsx b/packages/core/src/Button/XDSButton.tsxindex f7dcd38938..e9f770327c 100644--- a/packages/core/src/Button/XDSButton.tsx+++ b/packages/core/src/Button/XDSButton.tsx@@ -81,7 +81,7 @@ const variants = stylex.create({':focus-visible': `2px solid ${color.focusOutline}`,},outlineOffset: {- default: '0',+ default: null,':focus-visible': '3px',},},@@ -98,7 +98,7 @@ const variants = stylex.create({':focus-visible': `2px solid ${color.focusOutline}`,},outlineOffset: {- default: '0',+ default: null,':focus-visible': '3px',},},@@ -115,7 +115,7 @@ const variants = stylex.create({':focus-visible': `2px solid ${color.focusOutline}`,},outlineOffset: {- default: '0',+ default: null,':focus-visible': '3px',},},@@ -132,7 +132,7 @@ const variants = stylex.create({':focus-visible': `2px solid ${color.negative}`,},outlineOffset: {- default: '0',+ default: null,':focus-visible': '3px',},},diff --git a/yarn.lock b/yarn.lockindex 2418913ff3..88c75fa5ff 100644--- a/yarn.lock+++ b/yarn.lock@@ -1772,18 +1772,6 @@babel-plugin-syntax-hermes-parser "^0.26.0"esbuild "^0.24.0"-"@stylexjs/postcss-plugin@^0.17.5":- version "0.17.5"- resolved "https://registry.yarnpkg.com/@stylexjs/postcss-plugin/-/postcss-plugin-0.17.5.tgz#03ecd009409cbcb59e5083cac8a62f591ec38e16"- integrity sha512-GeveZXN8aDrXTSRpDM0SvCjmmY7WCfoel+lWcsf47QcJvjz5auGmh3a9LhIFLpwmAgpsVr20RyB8yxX93NaKow==- dependencies:- "@babel/core" "^7.26.8"- "@stylexjs/babel-plugin" "0.17.5"- fast-glob "^3.3.2"- glob-parent "^6.0.2"- is-glob "^4.0.3"- postcss "^8.4.49"-"@stylexjs/[email protected]":version "0.11.1"resolved "https://registry.yarnpkg.com/@stylexjs/shared/-/shared-0.11.1.tgz#c92160f33161f5721f5e1b4a623f99892df5d319"@@ -1814,6 +1802,19 @@invariant "^2.2.4"styleq "0.2.1"+"@stylexjs/unplugin@^0.17.4":+ version "0.17.5"+ resolved "https://registry.yarnpkg.com/@stylexjs/unplugin/-/unplugin-0.17.5.tgz#a21780504e8408a378ddade8281ba69820428f68"+ integrity sha512-ygKFNN3vUeZsmH++fGYm/XDecuNZzqTzCsU4XMiKqUpWwCb7YTJitptLASTk7Qe+dz1bpwmdWfFDUR55Us7WfA==+ dependencies:+ "@babel/core" "^7.26.8"+ "@babel/plugin-syntax-flow" "^7.26.0"+ "@babel/plugin-syntax-jsx" "^7.25.9"+ "@babel/plugin-syntax-typescript" "^7.25.9"+ "@stylexjs/babel-plugin" "0.17.5"+ browserslist "^4.24.0"+ lightningcss "^1.29.1"+"@testing-library/[email protected]":version "10.4.0"resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-10.4.0.tgz#82a9d9462f11d240ecadbf406607c6ceeeff43a8"@@ -2194,17 +2195,6 @@ ast-types@^0.16.1:dependencies:tslib "^2.0.1"-autoprefixer@^10.4.23:- version "10.4.23"- resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.23.tgz#c6aa6db8e7376fcd900f9fd79d143ceebad8c4e6"- integrity sha512-YYTXSFulfwytnjAPlw8QHncHJmlvFKtczb8InXaAx9Q0LbfDnfEYDE55omerIJKihhmU61Ft+cAOSzQVaBUmeA==- dependencies:- browserslist "^4.28.1"- caniuse-lite "^1.0.30001760"- fraction.js "^5.3.4"- picocolors "^1.1.1"- postcss-value-parser "^4.2.0"-available-typed-arrays@^1.0.7:version "1.0.7"resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846"@@ -2277,7 +2267,7 @@ browser-assert@^1.2.1:resolved "https://registry.yarnpkg.com/browser-assert/-/browser-assert-1.2.1.tgz#9aaa5a2a8c74685c2ae05bfe46efd606f068c200"integrity sha512-nfulgvOR6S4gt9UKCeGJOuSGBPGiFT6oQ/2UBnvTY/5aQ1PnksW72fhZkM30DzoRRv2WpwZf1vHHEr3mtuXIWQ==-browserslist@^4.24.0, browserslist@^4.28.1:+browserslist@^4.24.0:version "4.28.1"resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.28.1.tgz#7f534594628c53c63101079e27e40de490456a95"integrity sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==@@ -2331,7 +2321,7 @@ callsites@^3.0.0:resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==-caniuse-lite@^1.0.30001759, caniuse-lite@^1.0.30001760:+caniuse-lite@^1.0.30001759:version "1.0.30001764"resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001764.tgz#03206c56469f236103b90f9ae10bcb8b9e1f6005"integrity sha512-9JGuzl2M+vPL+pz70gtMF9sHdMFbY9FJaQBi186cHKH3pSzDvzoUJUPV6fqiKIMyXbud9ZLg4F3Yza1vJ1+93g==@@ -2518,6 +2508,11 @@ detect-indent@^6.0.0:resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6"integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==+detect-libc@^2.0.3:+ version "2.1.2"+ resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.1.2.tgz#689c5dcdc1900ef5583a4cb9f6d7b473742074ad"+ integrity sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==+dir-glob@^3.0.1:version "3.0.1"resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f"@@ -2875,7 +2870,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==-fast-glob@^3.2.9, fast-glob@^3.3.2:+fast-glob@^3.2.9:version "3.3.3"resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.3.tgz#d06d585ce8dba90a16b0505c543c3ccfb3aeb818"integrity sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==@@ -2975,11 +2970,6 @@ foreground-child@^3.1.0:cross-spawn "^7.0.6"signal-exit "^4.0.1"-fraction.js@^5.3.4:- version "5.3.4"- resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-5.3.4.tgz#8c0fcc6a9908262df4ed197427bdeef563e0699a"- integrity sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ==-fs-extra@^7.0.1:version "7.0.1"resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"@@ -3465,6 +3455,80 @@ levn@^0.4.1:prelude-ls "^1.2.1"type-check "~0.4.0"+ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-android-arm64/-/lightningcss-android-arm64-1.31.1.tgz#609ff48332adff452a8157a7c2842fd692a8eac4"+ integrity sha512-HXJF3x8w9nQ4jbXRiNppBCqeZPIAfUo8zE/kOEGbW5NZvGc/K7nMxbhIr+YlFlHW5mpbg/YFPdbnCh1wAXCKFg==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.31.1.tgz#a13da040a7929582bab3ace9a67bdc146e99fc2d"+ integrity sha512-02uTEqf3vIfNMq3h/z2cJfcOXnQ0GRwQrkmPafhueLb2h7mqEidiCzkE4gBMEH65abHRiQvhdcQ+aP0D0g67sg==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.31.1.tgz#f7482c311273571ec0c2bd8277c1f5f6e90e03a4"+ integrity sha512-1ObhyoCY+tGxtsz1lSx5NXCj3nirk0Y0kB/g8B8DT+sSx4G9djitg9ejFnjb3gJNWo7qXH4DIy2SUHvpoFwfTA==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.31.1.tgz#91df1bb290f1cb7bb2af832d7d0d8809225e0124"+ integrity sha512-1RINmQKAItO6ISxYgPwszQE1BrsVU5aB45ho6O42mu96UiZBxEXsuQ7cJW4zs4CEodPUioj/QrXW1r9pLUM74A==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.31.1.tgz#c3cad5ae8b70045f21600dc95295ab6166acf57e"+ integrity sha512-OOCm2//MZJ87CdDK62rZIu+aw9gBv4azMJuA8/KB74wmfS3lnC4yoPHm0uXZ/dvNNHmnZnB8XLAZzObeG0nS1g==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.31.1.tgz#a5c4f6a5ac77447093f61b209c0bd7fef1f0a3e3"+ integrity sha512-WKyLWztD71rTnou4xAD5kQT+982wvca7E6QoLpoawZ1gP9JM0GJj4Tp5jMUh9B3AitHbRZ2/H3W5xQmdEOUlLg==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.31.1.tgz#af26ab8f829b727ada0a200938a6c8796ff36900"+ integrity sha512-mVZ7Pg2zIbe3XlNbZJdjs86YViQFoJSpc41CbVmKBPiGmC4YrfeOyz65ms2qpAobVd7WQsbW4PdsSJEMymyIMg==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.31.1.tgz#a891d44e84b71c0d88959feb9a7522bbf61450ee"+ integrity sha512-xGlFWRMl+0KvUhgySdIaReQdB4FNudfUTARn7q0hh/V67PVGCs3ADFjw+6++kG1RNd0zdGRlEKa+T13/tQjPMA==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.31.1.tgz#8c8b21def851f4d477fa897b80cb3db2b650bc6e"+ integrity sha512-eowF8PrKHw9LpoZii5tdZwnBcYDxRw2rRCyvAXLi34iyeYfqCQNA9rmUM0ce62NlPhCvof1+9ivRaTY6pSKDaA==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.31.1.tgz#79000fb8c57e94a91b8fc643e74d5a54407d7080"+ integrity sha512-aJReEbSEQzx1uBlQizAOBSjcmr9dCdL3XuC/6HLXAxmtErsj2ICo5yYggg1qOODQMtnjNQv2UHb9NpOuFtYe4w==++ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.31.1.tgz#7f025274c81c7d659829731e09c8b6f442209837"+ integrity sha512-I9aiFrbd7oYHwlnQDqr1Roz+fTz61oDDJX7n9tYF9FJymH1cIN1DtKw3iYt6b8WZgEjoNwVSncwF4wx/ZedMhw==++lightningcss@^1.29.1:+ version "1.31.1"+ resolved "https://registry.yarnpkg.com/lightningcss/-/lightningcss-1.31.1.tgz#1a19dd327b547a7eda1d5c296ebe1e72df5a184b"+ integrity sha512-l51N2r93WmGUye3WuFoN5k10zyvrVs0qfKBhyC5ogUQ6Ew6JUSswh78mbSO+IU3nTWsyOArqPCcShdQSadghBQ==+ dependencies:+ detect-libc "^2.0.3"+ optionalDependencies:+ lightningcss-android-arm64 "1.31.1"+ lightningcss-darwin-arm64 "1.31.1"+ lightningcss-darwin-x64 "1.31.1"+ lightningcss-freebsd-x64 "1.31.1"+ lightningcss-linux-arm-gnueabihf "1.31.1"+ lightningcss-linux-arm64-gnu "1.31.1"+ lightningcss-linux-arm64-musl "1.31.1"+ lightningcss-linux-x64-gnu "1.31.1"+ lightningcss-linux-x64-musl "1.31.1"+ lightningcss-win32-arm64-msvc "1.31.1"+ lightningcss-win32-x64-msvc "1.31.1"+lilconfig@^3.1.1:version "3.1.3"resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.3.tgz#a1bcfd6257f9585bf5ae14ceeebb7b559025e4c4"@@ -3893,12 +3957,12 @@ postcss-load-config@^6.0.1:dependencies:lilconfig "^3.1.1"-postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0:+postcss-value-parser@^4.1.0:version "4.2.0"resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==-postcss@^8.4.43, postcss@^8.4.49:+postcss@^8.4.43:version "8.5.6"resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.6.tgz#2825006615a619b4f62a9e7426cc120b349a8f3c"integrity sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==