Commit d3a0a483d9f for woocommerce
commit d3a0a483d9f638f0045348309f53e98cf2700a41
Author: Francesco <frosso@users.noreply.github.com>
Date: Tue Oct 6 10:21:43 2026 +0200
fix: RTL styles for JS chunks (#69331)
diff --git a/packages/js/internal-build/src/style-build/webpack-rtl-plugin.cjs b/packages/js/internal-build/src/style-build/webpack-rtl-plugin.cjs
index 7c1af403b33..f55f49b16c5 100644
--- a/packages/js/internal-build/src/style-build/webpack-rtl-plugin.cjs
+++ b/packages/js/internal-build/src/style-build/webpack-rtl-plugin.cjs
@@ -13,8 +13,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
*/
const rtlcss = require( 'rtlcss' );
+const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const pluginName = 'WebpackRTLPlugin';
+const cssRe = /\.css(?:$|\?)/;
class WebpackRTLPlugin {
constructor( options ) {
@@ -28,7 +30,23 @@ class WebpackRTLPlugin {
}
apply( compiler ) {
+ const filenameSuffix = this.options.filenameSuffix || '-rtl$&';
+
compiler.hooks.thisCompilation.tap( pluginName, ( compilation ) => {
+ // WordPress only swaps in RTL files for stylesheets it enqueues, not lazy chunks.
+ // `data-href` keeps the LTR URL so the runtime can still find the loaded tag.
+ if ( ! this.options.inPlace ) {
+ MiniCssExtractPlugin.getCompilationHooks(
+ compilation
+ ).beforeTagInsert.tap(
+ pluginName,
+ ( source, { tag, href } ) =>
+ `${ source }\nif (document.dir === "rtl") { ${ tag }.setAttribute("data-href", ${ href }); ${ tag }.href = ${ href }.replace(${ cssRe }, ${ JSON.stringify(
+ filenameSuffix
+ ) }); }`
+ );
+ }
+
compilation.hooks.processAssets.tapPromise(
{
name: pluginName,
@@ -36,7 +54,6 @@ class WebpackRTLPlugin {
.PROCESS_ASSETS_STAGE_DERIVED,
},
async ( assets ) => {
- const cssRe = /\.css(?:$|\?)/;
return Promise.all(
[ ...compilation.chunks ]
.flatMap( ( chunk ) =>
@@ -81,7 +98,7 @@ class WebpackRTLPlugin {
// Compute the filename
const filename = asset.replace(
cssRe,
- this.options.filenameSuffix || '-rtl$&'
+ filenameSuffix
);
const assetInstance = assets[ asset ];
chunk.files.add( filename );
diff --git a/plugins/woocommerce/changelog/fix-rtl-lazy-chunk-css b/plugins/woocommerce/changelog/fix-rtl-lazy-chunk-css
new file mode 100644
index 00000000000..db21e30d0b7
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-rtl-lazy-chunk-css
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Load right-to-left styles on admin pages that load their styles on demand, such as the setup task list.