Commit 57d39d0ad16 for woocommerce

commit 57d39d0ad16f6039eb50117edd39bfe8cecb72f4
Author: Vladimir Reznichenko <kalessil@gmail.com>
Date:   Fri Apr 17 18:45:41 2026 +0200

    [dev] Monorepo: wrap up patching custom Webpack plugins (#64210)

diff --git a/packages/js/internal-style-build/style-asset-plugin.js b/packages/js/internal-style-build/style-asset-plugin.js
index 7c76fa0d731..52c0db34b84 100644
--- a/packages/js/internal-style-build/style-asset-plugin.js
+++ b/packages/js/internal-style-build/style-asset-plugin.js
@@ -11,12 +11,7 @@
  * External dependencies
  */
 const path = require( 'path' );
-const webpack = require( 'webpack' );
 const json2php = require( 'json2php' );
-const { createHash } = webpack.util;
-
-const { RawSource } = webpack.sources;
-const { AsyncDependenciesBlock } = webpack;

 class AssetDataPlugin {
 	constructor( options ) {
@@ -46,6 +41,9 @@ class AssetDataPlugin {
 	}

 	apply( compiler ) {
+		const { createHash } = compiler.webpack.util;
+		const { RawSource } = compiler.webpack.sources;
+
 		compiler.hooks.thisCompilation.tap(
 			this.constructor.name,
 			( compilation ) => {
@@ -55,14 +53,14 @@ class AssetDataPlugin {
 						stage: compiler.webpack.Compilation
 							.PROCESS_ASSETS_STAGE_ANALYSE,
 					},
-					() => this.addAssets( compilation )
+					() => this.addAssets( compilation, createHash, RawSource )
 				);
 			}
 		);
 	}

 	/** @param {webpack.Compilation} compilation */
-	addAssets( compilation ) {
+	addAssets( compilation, createHash, RawSource ) {
 		const {
 			combineAssets,
 			combinedOutputFile,
@@ -163,58 +161,6 @@ class AssetDataPlugin {
 			);
 		}
 	}
-
-	/**
-	 * Can we trace a line of static dependencies from an entry to a module
-	 *
-	 * @param {webpack.Compilation}       compilation
-	 * @param {webpack.DependenciesBlock} block
-	 *
-	 * @return {boolean} True if there is a static import path to the root
-	 */
-	static hasStaticDependencyPathToRoot( compilation, block ) {
-		const incomingConnections = [
-			...compilation.moduleGraph.getIncomingConnections( block ),
-		].filter(
-			( connection ) =>
-				// Library connections don't have a dependency, this is a root
-				connection.dependency &&
-				// Entry dependencies are another root
-				connection.dependency.constructor.name !== 'EntryDependency'
-		);
-
-		// If we don't have non-entry, non-library incoming connections,
-		// we've reached a root of
-		if ( ! incomingConnections.length ) {
-			return true;
-		}
-
-		const staticDependentModules = incomingConnections.flatMap(
-			( connection ) => {
-				const { dependency } = connection;
-				const parentBlock =
-					compilation.moduleGraph.getParentBlock( dependency );
-
-				return parentBlock.constructor.name !==
-					AsyncDependenciesBlock.name
-					? [ compilation.moduleGraph.getParentModule( dependency ) ]
-					: [];
-			}
-		);
-
-		// All the dependencies were Async, the module was reached via a dynamic import
-		if ( ! staticDependentModules.length ) {
-			return false;
-		}
-
-		// Continue to explore any static dependencies
-		return staticDependentModules.some( ( parentStaticDependentModule ) =>
-			AssetDataPlugin.hasStaticDependencyPathToRoot(
-				compilation,
-				parentStaticDependentModule
-			)
-		);
-	}
 }

 module.exports = AssetDataPlugin;
diff --git a/plugins/woocommerce/client/admin/bin/unminify-webpack-plugin.js b/plugins/woocommerce/client/admin/bin/unminify-webpack-plugin.js
index c80ed8f7b7c..e149ebb1444 100644
--- a/plugins/woocommerce/client/admin/bin/unminify-webpack-plugin.js
+++ b/plugins/woocommerce/client/admin/bin/unminify-webpack-plugin.js
@@ -12,7 +12,6 @@
  */
 const path = require( 'path' );
 const ModuleFilenameHelpers = require( 'webpack/lib/ModuleFilenameHelpers' );
-const webpack = require( 'webpack' );

 const getFileName = ( name, ext, opts ) => {
 	if ( name.match( /([-_.]min)[-_.]/ ) ) {
@@ -47,7 +46,7 @@ class UnminifyWebpackPlugin {
 				compilation.hooks.processAssets.tap(
 					{
 						name: 'UnminifyWebpackPlugin',
-						stage: webpack.Compilation.PROCESS_ASSETS_STAGE_DERIVED,
+						stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_DERIVED,
 					},
 					( assets ) => {
 						Object.entries( assets ).forEach(
@@ -105,7 +104,7 @@ class UnminifyWebpackPlugin {
 						) ) {
 							compilation.emitAsset(
 								value.filename,
-								new webpack.sources.RawSource( value.content )
+								new compiler.webpack.sources.RawSource( value.content )
 							);
 							// Reset the outputNormal object to avoid writing to file that only differs in casing or query string from already written file.
 							outputNormal = {};