diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5d9eb7a..3ef47cf2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -900,8 +900,8 @@ importers: specifier: ^2.1.1 version: 2.1.1(@rsbuild/core@2.2.12)(@rspack/core@2.3.3) '@stylexjs/unplugin': - specifier: ^0.19.1 - version: 0.19.1(supports-color@9.4.0)(unplugin@2.3.11) + specifier: ^0.19.2 + version: 0.19.2(supports-color@9.4.0)(unplugin@2.3.11) '@types/node': specifier: ^24.19.2 version: 24.19.2 @@ -9062,17 +9062,20 @@ packages: typescript: optional: true - '@stylexjs/babel-plugin@0.19.1': - resolution: {integrity: sha512-Ig3crX6MuGWDEAx+f89aLxTQUWVeEc2Aco2moIdcObyvo7hZJgU26rxJN3k7geFjhi+5dfna6TNR8iTRK0PQGA==} + '@stylexjs/babel-plugin@0.19.2': + resolution: {integrity: sha512-R6cB7Ym+IAvySNfmtRJ6CZ+83rjZ82Uw4wmG3YtwYY8vrnliUrYy9fOLvZ1nX407zeHNkCnE5AodEnjXXfOSYg==} - '@stylexjs/shared@0.19.1': - resolution: {integrity: sha512-oFBtW0NPNLJOT1gLweWRNKrIJHjJMwOmSV7fgd6ewok4fwb/Nh95PEaYGKu+ZONk0nNghjLFfOwiIsxJdvh3TQ==} + '@stylexjs/shared@0.19.2': + resolution: {integrity: sha512-xjTZ/6T/1FV103F2bspmXoDRDy1gM/ZKYEHpQlUC0h4R5q7PqUV6k+DJbrayRAMwALIdzTf7zSTqteRde0ZXWQ==} '@stylexjs/stylex@0.19.1': resolution: {integrity: sha512-JwNFm0MOYPqi+M4Ax5Un4ZxfZp4HEAX2sAWetZ88KALFcv1eEiHNJs75oO3V3U7RVWnzfkiM8i9eBowC3hqgUw==} - '@stylexjs/unplugin@0.19.1': - resolution: {integrity: sha512-MJz/IPrFe3hSHbZtjbxaYd3kLgS718/NFBEY/Mf+njteJKLdY7bHHfVka3051LCYy9fKfyZapGCmUpibraHqmQ==} + '@stylexjs/stylex@0.19.2': + resolution: {integrity: sha512-l0fRhOBZ4rFiZ0GntYSlp4lYO5dPT11F3mLb7O4ShK6eE1WOjHtv9GHGQZuzHJbQkjcEaRjPSpBn6itI7yXc3Q==} + + '@stylexjs/unplugin@0.19.2': + resolution: {integrity: sha512-kyHrLCVyKNmycPl+WnjVGJmPgKGAYbtVPasuCe3UgQllennwj2himUKQncG98zt+66nDuGpy7Sx2xCYM03nr3Q==} peerDependencies: unplugin: ^2.3.11 @@ -17751,6 +17754,11 @@ snapshots: '@babel/core': 7.29.7(supports-color@9.4.0) '@babel/helper-plugin-utils': 7.29.7 + '@babel/plugin-syntax-flow@7.28.6(@babel/core@7.29.13)': + dependencies: + '@babel/core': 7.29.13(supports-color@9.4.0) + '@babel/helper-plugin-utils': 7.29.7 + '@babel/plugin-syntax-flow@7.28.6(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7(supports-color@9.4.0) @@ -17786,6 +17794,11 @@ snapshots: '@babel/core': 7.29.7(supports-color@9.4.0) '@babel/helper-plugin-utils': 7.29.7 + '@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.13)': + dependencies: + '@babel/core': 7.29.13(supports-color@9.4.0) + '@babel/helper-plugin-utils': 7.29.7 + '@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7(supports-color@9.4.0) @@ -21862,14 +21875,6 @@ snapshots: '@module-federation/runtime-tools': 2.9.2 '@swc/helpers': 0.5.24 - '@rspack/core@2.3.3(@module-federation/runtime-tools@2.9.2)(@swc/helpers@0.5.23)': - dependencies: - '@rspack/binding': 2.3.3 - optionalDependencies: - '@module-federation/runtime-tools': 2.9.2 - '@swc/helpers': 0.5.23 - optional: true - '@rspack/core@2.3.3(@module-federation/runtime-tools@2.9.2)(@swc/helpers@0.5.24)': dependencies: '@rspack/binding': 2.3.3 @@ -21934,7 +21939,7 @@ snapshots: dependencies: react-refresh: 0.19.0 optionalDependencies: - '@rspack/core': 2.3.3(@module-federation/runtime-tools@2.9.2)(@swc/helpers@0.5.23) + '@rspack/core': 2.3.3(@module-federation/runtime-tools@2.9.2)(@swc/helpers@0.5.24) '@rspack/plugin-react-refresh@2.0.2(@rspack/core@2.3.4)(react-refresh@0.19.0)': dependencies: @@ -22610,20 +22615,20 @@ snapshots: optionalDependencies: typescript: 5.9.3 - '@stylexjs/babel-plugin@0.19.1(supports-color@9.4.0)': + '@stylexjs/babel-plugin@0.19.2(supports-color@9.4.0)': dependencies: - '@babel/core': 7.29.7(supports-color@9.4.0) + '@babel/core': 7.29.13(supports-color@9.4.0) '@babel/helper-module-imports': 7.29.7(supports-color@9.4.0) - '@babel/traverse': 7.29.8(supports-color@9.4.0) - '@babel/types': 7.29.8 + '@babel/traverse': 7.29.14(supports-color@9.4.0) + '@babel/types': 7.29.14 '@dual-bundle/import-meta-resolve': 4.1.0 - '@stylexjs/shared': 0.19.1 - '@stylexjs/stylex': 0.19.1 + '@stylexjs/shared': 0.19.2 + '@stylexjs/stylex': 0.19.2 postcss-value-parser: 4.2.0 transitivePeerDependencies: - supports-color - '@stylexjs/shared@0.19.1': {} + '@stylexjs/shared@0.19.2': {} '@stylexjs/stylex@0.19.1': dependencies: @@ -22631,14 +22636,18 @@ snapshots: invariant: 2.2.4 styleq: 0.2.1 - '@stylexjs/unplugin@0.19.1(supports-color@9.4.0)(unplugin@2.3.11)': + '@stylexjs/stylex@0.19.2': dependencies: - '@babel/core': 7.29.7(supports-color@9.4.0) - '@babel/plugin-syntax-flow': 7.28.6(@babel/core@7.29.7) - '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.7) - '@babel/plugin-syntax-typescript': 7.29.7(@babel/core@7.29.7) - '@stylexjs/babel-plugin': 0.19.1(supports-color@9.4.0) - browserslist: 4.29.3 + styleq: 0.2.1 + + '@stylexjs/unplugin@0.19.2(supports-color@9.4.0)(unplugin@2.3.11)': + dependencies: + '@babel/core': 7.29.13(supports-color@9.4.0) + '@babel/plugin-syntax-flow': 7.28.6(@babel/core@7.29.13) + '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.13) + '@babel/plugin-syntax-typescript': 7.29.7(@babel/core@7.29.13) + '@stylexjs/babel-plugin': 0.19.2(supports-color@9.4.0) + browserslist: 4.29.5 lightningcss: 1.33.0 unplugin: 2.3.11 transitivePeerDependencies: diff --git a/rsbuild/stylex/README.md b/rsbuild/stylex/README.md index 4123fce0..a0314343 100644 --- a/rsbuild/stylex/README.md +++ b/rsbuild/stylex/README.md @@ -6,8 +6,6 @@ During development, `runtimeInjection` injects StyleX styles at runtime so style In production, runtime injection is disabled. The plugin compiles StyleX at build time and appends the generated CSS to the stylesheet emitted by Rsbuild's `CssExtractRspackPlugin` (fed by `src/index.css`), producing content-hashed CSS filenames instead of a separate hardcoded `/stylex.css` link. -This example uses `stylex.webpack()` (not `stylex.rspack()`) because `@stylexjs/unplugin` currently attaches CSS injection through the webpack-compatible hook; Rspack still runs that hook for plugins registered via `tools.rspack.plugins`. - ## Setup Install the dependencies: diff --git a/rsbuild/stylex/package.json b/rsbuild/stylex/package.json index 80a7ddd0..1b707097 100644 --- a/rsbuild/stylex/package.json +++ b/rsbuild/stylex/package.json @@ -16,7 +16,7 @@ "devDependencies": { "@rsbuild/core": "2.2.12", "@rsbuild/plugin-react": "^2.1.1", - "@stylexjs/unplugin": "^0.19.1", + "@stylexjs/unplugin": "^0.19.2", "@types/node": "^24.19.2", "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", diff --git a/rsbuild/stylex/rsbuild.config.ts b/rsbuild/stylex/rsbuild.config.ts index 1d2434af..8f7db3bc 100644 --- a/rsbuild/stylex/rsbuild.config.ts +++ b/rsbuild/stylex/rsbuild.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from '@rsbuild/core'; import { pluginReact } from '@rsbuild/plugin-react'; -import stylex from '@stylexjs/unplugin'; +import stylexPlugin from '@stylexjs/unplugin/rspack'; export default defineConfig({ plugins: [pluginReact()], @@ -10,11 +10,7 @@ export default defineConfig({ // Official StyleX plugin: compiles StyleX and appends CSS into the // stylesheet emitted by CssExtractRspackPlugin (used by Rsbuild). // See https://stylexjs.com/docs/learn/installation/rspack/ - // - // Prefer the webpack adapter here: @stylexjs/unplugin currently attaches - // CSS injection via the webpack() hook, which Rspack still invokes for - // webpack-compatible plugins. The rspack() entry only runs transform. - stylex.webpack({ + stylexPlugin({ useCSSLayers: true, // Inject styles during development so they update with HMR. runtimeInjection: process.env.NODE_ENV === 'development',